, Mask v (, ):
Dim props As List(Of PropertyDescriptor) = (
From C As PropertyDescriptor In TypeDescriptor.GetProperties(v.GetType)
Where C.Attributes.OfType(Of MaskAttribute)().Count > 0
Select C
).ToList
System.ComponentModel
, ( Access vb.net):
Public Function GetPropertyValue(ByVal obj As Object, ByVal PropName As String) As Object
Dim objType As Type = obj.GetType()
Dim pInfo As System.Reflection.PropertyInfo = objType.GetProperty(PropName)
Dim PropValue As Object = pInfo.GetValue(obj, Reflection.BindingFlags.GetProperty, Nothing, Nothing, Nothing)
Return PropValue
End Function
, Name PropertyDescriptor props.
UPDATE
, , .
, :
Sub GetPropertiesWithMaskAttribute(Obj As Object, ByRef props As List(Of PropertyDescriptor))
Dim props1 As List(Of PropertyDescriptor) = (From C As PropertyDescriptor In TypeDescriptor.GetProperties(Obj) Select C).ToList
For Each prop In props1
If prop.Attributes.OfType(Of MaskAttribute)().Count > 0 Then
props.Add(prop)
Else
If prop.ComponentType.IsClass Then
GetPropertiesWithMaskAttribute(GetPropertyValue(Obj, prop.Name), props)
End If
End If
Next
End Sub
:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim props As New List(Of PropertyDescriptor)
GetPropertiesWithMaskAttribute(v, props)
End Sub
props MaskAtribute. , GetPropertyValue.