我是自定义属性的新手,所以我想知道是否可以获取属性的值。我使用自定义属性的类中的属性示例是:
Private mFiller As String
<Position(378), Length(34), DataType("A"), ParticipantDependant("P/D"), RequiredProperty("Required"), Format("Blank")> _
Public Property Filler() As String
Get
Return mFiller
End Get
Set(ByVal value As String)
mFiller = value
End Set
End Property
我正在尝试获取这些属性的值(即获取位置 = 378、长度 = 34 等)。我开始的循环看起来像这样:
Dim gwlImport As New ClientGWLImport
Dim properties() As PropertyInfo = gwlImport.GetType.GetProperties
Dim tmpInfo As PropertyInfo
For Each tmpInfo In properties
Debug.Print("Attributes for : " & tmpInfo.Name)
For Each tmpAttribute As Object In tmpInfo.GetCustomAttributes(True)
Debug.Print(tmpAttribute.ToString)
Next tmpAttribute
Next tmpInfo
这让我得到了所有属性的名称,但我不确定如何获取这些值。有任何想法吗?
干杯,
瑞安