I'm using Castle DynamicProxy to create a proxy of a given type at runtime - including a couple mixins.
I'm trying to figure out if it's possible to also开发者_Python百科 add arbitrary properties to the proxy, e.g.:
class BaseType
{
string Foo { get; set; }
}
and at runtime, I create a new type, that would look like this:
class BaseTypeProxy3848484etc
{
string Foo { get; set; }
OtherType Bar { get; set; }
}
In theory, it seems like this should be possible-- maybe I'm just not seeing how to do it with Castle... Any thoughts? Thanks!
Extending DynamicObject you can create a proxy of your instance and add behaviour to the properties you want to add.
精彩评论