|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Reflection and Genericsvalues of a given object. from each token I get a property name and using reflection, I get the value of the property. Some properties are generic lists, I can tell what is the type of the generic in the list (PropertyValue.GetType.GetGenericArguments) How can I cast the value returned by the InvokeMember call to the right generic type? in this sample "ClaimManagerItem" is a base class, GenericType will always be of class inheriting from the base class PropertyValue = SourceType.InvokeMember(PropertyName, Flags, Nothing, Source, Nothing) If PropertyValue.GetType.GetGenericArguments.Length <> 0 Then 'Generic Dim GenericType As Type = PropertyValue.GetType.GetGenericArguments(0) For Each CMItem As ClaimManagerItem In DirectCast(PropertyValue, GenericType(of ??? ) .... .... Next Thanks for the help |
|||||||||||||||||||||||