У меня есть объекты типа DynamicObject. Эти объекты будут использоваться библиотеками, которые работают с членами и используют отражение. Мне интересно, есть ли способ добиться следующего, то есть заставить отражение возвращать правильную информацию о члене (PropertyInfo):
Код: Выделить всё
public class TestDO : DynamicObject {
...
}
typeof(TestDO).getProperty("SomeProp"); // make this not return null
Some ideas are:
- Is it possible to generate the type information at runtime, so that I can just use typeof(MyJITCreatedType) (something like byte buddy in the Java world)?
- I have seen ICustomTypeProvider, but have no idea if that can be used (does not even exist in my project currently)?
- Is there some hook in DynamicObject I can implement?
- I cannot change the way the library consumes my object/uses reflection.
- I can potentially give information about which type is used (i.e. MyJITCreatedType instead of TestDO).
- I know the properties at runtime.
- I can change the implementation of TestDO
Источник: https://stackoverflow.com/questions/781 ... amicobject