If this is your first visit, be sure to
check out the
FAQ
by clicking the
link above. You may have to
register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
I'm trying to hide base methods in an inherited class, and I am using a method where a wrapper is used to return an interface of methods that are seen, like so:
vb.net Code:
Public Class MyWrapper
Private _MyStringList As MyStringList
Public Sub New()
Me._MyStringList = New MyStringList
End Sub
Private _List As IMyListFunctions
Public Property List() As IMyListFunctions
Get
Return _List
End Get
Set(ByVal value As IMyListFunctions)
_List = value
End Set
End Property
Private Class MyStringList
Inherits List(Of String)
Implements IMyListFunctions
Public Overloads Sub Add(ByVal item As String) Implements IMyListFunctions.Add
MyBase.Add(item)
End Sub
Public Overloads Function Contains(ByVal item As String) As Boolean Implements IMyListFunctions.Contains
Return MyBase.Contains(item)
End Function
End Class
Public Interface IMyListFunctions
Sub Add(ByVal item As String) 'Allow Add
Function Contains(ByVal item As String) As Boolean 'Allow Contains
End Interface
End Class
And what I am basically wondering is if there is an easier way to do this. Is there some sort of Compile attribute I can apply instead?
EDIT: The best way to do this (Microsoft does this) is to use these Attributes:
vb.net Code:
<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never), System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)> _
APropertyOrMethod
Overtop of a Method or Property, then if they are called throw NotSupportedExceptions.
Advertiser Disclosure:
Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.