Using System.Dynamic to introspect COM objects
How can I use IDynamicMetaObjectProvider to introspect COM objects? Specifically, given an arbitrary COM object, 开发者_如何学CI want to return a Dictionary where the Key is the Property name, and the Value is the string value of the property in the COM object (if the property value isn't a string, skip it).
How can I get the property names and their values at runtime like this?
You can't really; objects are not required to implement IDynamicMetaObjectProvider in order to provide dynamic functionality, it's a hook that allows them to contribute in the binding process.
For this kind of operation, you would still have to drop down to using Reflection to get the members and the values.
精彩评论