Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''<summary>Get a list of all available property names.</summary>
- Private Function GetAllPropertyNames(ByRef TypeToReflect As Type) As List(Of String)
- Dim RetVal As New List(Of String)
- Dim DescriptionAttribute As Type = GetType(System.ComponentModel.DescriptionAttribute)
- For Each SingleProperty As Reflection.PropertyInfo In TypeToReflect.GetProperties()
- Dim PropertyName As String = SingleProperty.Name
- Dim Description As String = GetDescriptionAttribute(CType(SingleProperty, Object))
- If String.IsNullOrEmpty(Description) = False Then PropertyName &= " (" & Description & ")"
- RetVal.Add(PropertyName)
- Next SingleProperty
- Return RetVal
- End Function
- Public Shared Function GetDescriptionAttribute(ByRef Element As Object) As String
- Try
- Dim attributes As System.ComponentModel.DescriptionAttribute() = CType(Element.GetType.GetField(Element.ToString).GetCustomAttributes(GetType(System.ComponentModel.DescriptionAttribute), False), System.ComponentModel.DescriptionAttribute())
- If attributes.Length > 0 Then Return attributes(0).Description Else Return String.Empty
- Catch ex As Exception
- Return String.Empty
- End Try
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement