I need to set DynamicObject property using string propertyName. I found the way to get property value using this answer, but when it comes to setValue I'm not quite sure how to rewrite the code in order to set the property. I receive runtime errors and not quite sure about expressions logic. I wonder if you can suggest any idea how to implement void SetProperty(object o, string member,object value)
method.
IDynamicMetaObjectProvider set property using literal name
431 Views Asked by Access Denied At
1
In some cases like
ExpandoObject
, then you can use theIDictionary<string,object>
API instead:In the more general case of
IDynamicMetaObjectProvider
: you could borrow theCallSiteCache
from FastMember:Note here that we could type
target
asIDynamicMetaObjectProvider
, but we don't actually need that - theCallSite
API doesn't require it.