Is it possible to use a dynamic class member? For example
class blarg
{
public dynamic ctx = new ExpandoObject();
}
without also making blarg inherit (and implement) from DynamicObject?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no fixed inheritance structure; firstly,
dynamiccan use reflection/meta-programming anyway, so you can just attach a regular class with members and it’ll work – but you won’t be able to add new members etc. Secondly, “all” you need to do to support fulldynamicis implementIDynamicMetaObjectProvider– not inherit something. The “all” is in quotes, because that isn’t trivial.DynamicObjectexists to do some of the heavy lifting for you, as doesExpandoObjectfor the cases when you just want a property-bag.But since the callers aren’t binding to any particular type (since they are using
dynamic), frankly it isn’t a huge problem to inherit fromDynamicObject.