views:

53

answers:

0

I have a a dynamic value (implementation of IDynamicMetaObjectProvider) that I'd like to call methods and properties on.

Examples I have found so far of invoking members on a dynamic value use types out of Microsoft.CSharp.dll, e.g.

IDynamicMetaObjectProvider x = GetDynamicValue();
CallSite<Func<CallSite, object, object, object>> site = CallSite<Func<CallSite, object, object, object>>.Create(
            Binder.SetMember(
                Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.None,
                "Foo",
                null,
                new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }
            )
        );
site.Target(site, x, 42);

I want to be able to invoke a IDynamicMetaObjectProvider's members without using Microsoft.CSharp.dll. Note that I am not talking about using the C# dynamic keyword on anything related to C# but using a IDynamicMetaObjectProvider directly.

Also note that using Reflection won't work. Reflection bypasses dynamic call binding and simply performs Reflection on the underlying type. I need a technique that works with any implementation of IDynamicMetaObjectProvider.