Get generic type of call to method in dynamic object

后端 未结 3 857
感动是毒
感动是毒 2021-02-07 08:49

I\'m starting to work with dynamic objects in .Net and I can\'t figure out how to do something.

I have a class that inherits from DynamicObject, and I override the TryIn

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 09:36

    The open source framework Dynamitey can call properties that internal/protected/private using the DLR and thus works with Silverlight. But it get's a little tricky with interface explicit members as you have to use the actual full name of the member on the the type, rather than the interface member name. So you can do:

    var typeArgs = Dynamic.InvokeGet(binder, "Microsoft.CSharp.RuntimeBinder.ICSharpInvokeOrInvokeMemberBinder.TypeArguments")
         as IList;
    

提交回复
热议问题