Question Reflection problem: need help

gstar

New member
Joined
Dec 13, 2009
Messages
1
Programming Experience
5-10
When the overriden property ID is passed to the indexer as propertyname="ID" reflection does not recognize it.
m_info comes up as nothing. I don't know how to fix it.
When i look in the class member viewer the ID property is described as "ID() As Integer" i have tried to pass this as the propertyname as well but it was no used GetProperty still can't find it. Please anyone???
I got the following class

Public Partial Class Customer
Inherits SomeBaseClassInWhichContainsIDMustOverride

Private _ID As System.Nullable(Of Integer)
Public Overrides Property ID() As Integer
Get
Return _ID
End Get
Set(ByVal value As Integer)
_ID = value
OnPropertyChanged("ID")
End Set
End Property

Dim m_info As PropertyInfo
Dim m_typeInfo As Type
Dim m_msg As String

' The indexer ...
Public Property Properties(ByVal PropertyName As String) As Object
Get
' Retrieve current type information ...
m_typeInfo = Me.GetType()
m_info = m_typeInfo.GetProperty(PropertyName.ToString())
m_msg = String.Format("{0} is not a valid property of {1}", _
PropertyName, _
m_typeInfo.Name)

If (m_info Is Nothing) Then
Throw New ArgumentException(m_msg)
End If
Return m_info.GetValue(Me, Nothing)
End Get
Set(ByVal Value As Object)
' Retrieve current type information ...
m_typeInfo = Me.GetType()
m_info = m_typeInfo.GetProperty(PropertyName.ToString())
m_msg = String.Format("{0} is not a valid property of {1}", _
PropertyName, _
m_typeInfo.Name)
If (m_info Is Nothing) Then
Throw New ArgumentException(m_msg)
End If
m_info.SetValue(Me, Value, Nothing)
End Set
End Property
End Class
 
Back
Top