'*** cslaDim cslaList As MyTestTypeList = MyTestTypeList.GetList'*** non-csla with inherited subclass and withoutDim list As New MyTestTypeList2Dim list2 As New EnumList2(Of MyTestType)'*** enum we are usingPublic Enum MyTestType something = 1 here = 2 ok = 3End Enum'*** csla<Serializable()> _Public Class MyTestTypeList Inherits EnumList(Of mytesttype, MyTestTypeList)End Class<Serializable()> _Public Class EnumList(Of T As Structure, R As EnumList(Of T, R)) Inherits Csla.NameValueListBase(Of String, Integer) Public Shared Function GetList() As R Return Csla.DataPortal.Fetch(Of R)() End Function Protected Sub New() ' require use of factory method End Sub <Csla.RunLocal()> _ Public Overloads Sub DataPortal_Fetch() 'ByVal criteria As Object) Me.IsReadOnly = False For Each item As T In [Enum].GetValues(GetType(T)) Dim name As String = [Enum].GetName(GetType(T), item) Add(New Csla.NameValueListBase(Of String, Integer).NameValuePair(name, [Enum].Parse(GetType(T), name))) Next Me.IsReadOnly = True End Sub End Class'*** non-cslaPublic Class MyTestTypeList2 Inherits EnumList2(Of MyTestType)End ClassPublic Class EnumList2(Of T As Structure) Inherits List(Of EnumListItem) Public Structure EnumListItem Dim Name As String Dim Value As Integer Public Sub New(ByVal name As String, ByVal value As Integer) Me.Name = name Me.Value = value End Sub End Structure Public Sub New() For Each item As T In [Enum].GetValues(GetType(T)) Dim name As String = [Enum].GetName(GetType(T), item) Add(New EnumListItem(name, [Enum].Parse(GetType(T), name))) Next End SubEnd Class
Remember Me
Powered by: newtelligence dasBlog 2.3.9074.18820
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
E-mail
Theme design by Jelle Druyts