我有一个清单......
Public Class DatabaseCollection(Of T)
Inherits List(Of T)
Private Shared _LookupTables As Dictionary(Of String, IEnumerable)
Public Shared ReadOnly Property LookupTables As Dictionary(Of String, IEnumerable)
Get
If _LookupTables Is Nothing Then
_LookupTables = New Dictionary(Of String, IEnumerable)
End If
Return _LookupTables
End Get
End Property
End Class
我想从其他地方访问此属性。
我该怎么做?
答案 0 :(得分:0)
我创建了一个新类Schema
,它有一个共享属性,包含每种类型的元信息字典,包括LookupTable。 Schema
构造函数采用有问题的类型,因此没有歧义。
答案 1 :(得分:-1)
编辑:
我能想到的最好的方法是处理包含DatabaseCollection类的另一个对象。因此,您的DatabaseCollection对象将是“Container”对象的公共属性。然后你也可以将你的LookupTable放在'Container'对象中,每个DatabaseCollection会关联1-1。
除了DatabaseCollection类(如果你有其他属性/方法。如果你没有,那么它可能只是一个通用列表。)并且还包括以下内容:
Public Class ContainerForDatabaseCollection
Private Property _DbCollection as new DatabaseCollection
Public Readonly Property DbCollection as DatabaseCollection(of String)
Get
return _DbCollection
End Get
End Property
Private Shared Property _LookupTables As Dictionary(Of String, IEnumerable)
Public Shared ReadOnly Property LookupTables As Dictionary(Of String, IEnumerable)
Get
If _LookupTables Is Nothing Then
_LookupTables = New Dictionary(Of String, IEnumerable)
End If
Return _LookupTables
End Get
End Property
public Sub New() 'Possibly include parameters for private properties...
'Initialize Private properties
End Sub
End Class