Pages

Showing posts with label Get property value from C# dynamic object by string using reflection. Show all posts
Showing posts with label Get property value from C# dynamic object by string using reflection. Show all posts

Get property value from C# dynamic object by string using reflection

Tuesday, December 10, 2013

In Generic Class, it is quite common to get the value for a specific property dynamically. C# refection provides ways to get the Property value dynamically. If the IDynamicMetaObjectProvider can provide the dynamic member names, you can get them. See GetMemberNames implementation in the apache licensed ImpromptuInterface (which can be found in nuget), it works for ExpandoObjects and DynamicObjects that implement GetDynamicMemberNames and any other IDynamicMetaObjectProvider who provides a meta object with an implementation of GetDynamicMemberNames without custom testing beyond is IDynamicMetaObjectProvider.