I have an ExpandoObject
and want to make a getter for it that will return a property by name at runtime, where the name is specified in a string instead of hard
ExpandoObject
provides access both via dynamic
and via IDictionary<string,object>
- so you could just use the dictionary API:
var byName = (IDictionary<string,object>)account.features;
bool val = (bool)byName["isEmailEnabled"];
Or if the name is fixed, just:
bool val = ((dynamic)account).features.isEmailEnabled;