views:

63

answers:

1

Is it possible to find all the available fields/properties that currently exist on dynamic object?

I want to do this for all objects that implement IDynamicMetaObjectProvider. Using GetDynamicMemberNames() isn't suitable as it doesn't have to be fully implemented by custom dynamic classes, it can just return an empty enumeration.

I don't want to check for the presence of a named property i.e. "Name" or "Id", but I want to get a list of all the current properties, is this possible?

+2  A: 

I don't see how you could, no - a dynamic class can do what it likes when it comes to deeming a property to "exist" or not. You could write a dynamic class which allowed access to any property name so long as it's before midday, and nothing in the afternoon, for example.

GetDynamicMemberNames() is the way that a dynamic object is meant to advertise its members... if it doesn't do so, you'd basically be trying to solve the halting problem in order to find every "known" member.

Jon Skeet
Cheers, that's what I suspected, but I just wanted to check if I was missing something.
Matt Warren
So basically Microsoft really dropped the ball with dynamics.
Chris Marisic