Esempio n. 1
0
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            Type type;

            Activate buildType;

            if (!_buildType.TryGetValue(binder.Name, out buildType))
            {
                buildType = null;
            }

            if (buildType == null && !_buildType.TryGetValue("Object", out buildType))
            {
                buildType = null;
            }

            result = InvokeHelper(binder.CallInfo, args, buildType);
            if (GetTypeForPropertyNameFromInterface(binder.Name, out type))
            {
                if (type.IsInterface && result != null && !type.IsAssignableFrom(result.GetType()))
                {
                    result = InvocationBinding.DynamicDressedAs(result, type);
                }
            }
            return(true);
        }
Esempio n. 2
0
        private static object InterfaceProjection(Type theType, object itf)
        {
            if (itf is IDictionary <string, object> && !(itf is AbstractShapeableExpando))
            {
                itf = new ShapeableExpando((IDictionary <string, object>)itf);
            }
            else
            {
                itf = new DynamicPropertiesToReflectablePropertiesProxy(itf);
            }

            itf = InvocationBinding.DynamicDressedAs(itf, theType);
            return(itf);
        }