Esempio n. 1
0
 public void MaybeInitialize(ShapeableExpando extensions, object target)
 {
     if (!_isInitialized)
     {
         Initialize(extensions, target);
         _isInitialized = true;
     }
 }
 public bool Equals(ShapeableExpando other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other._dictionary, _dictionary));
 }
Esempio n. 3
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);
        }
Esempio n. 4
0
        private static object WireUpForInterfaceUsingType(bool gotType, Type theType, ShapeableObject bindSite,
                                                          object itf)
        {
            if (IsDictionaryButNotExpando(itf, gotType, theType))
            {
                itf = new ShapeableExpando((IDictionary <string, object>)itf);
            }
            else if (gotType)
            {
                if (itf != null && !theType.IsAssignableFrom(itf.GetType()))
                {
                    if (theType.IsInterface)
                    {
                        itf = InterfaceProjection(theType, itf);
                    }
                    else
                    {
                        try
                        {
                            object tResult;

                            tResult = InvocationBinding.Conversion(bindSite, theType, explict: true);

                            itf = tResult;
                        }
                        catch (RuntimeBinderException)
                        {
                            itf = MaybeConvert(theType, itf);
                        }
                    }
                }
                else if (null == itf && theType.IsValueType)
                {
                    itf = InvocationBinding.CreateInstance(theType);
                }
            }

            return(itf);
        }
Esempio n. 5
0
 public virtual bool InterceptAfter(Invocation invocation, object target, ShapeableExpando extensions,
                                    out object resultData)
 {
     resultData = null;
     return(true);
 }
Esempio n. 6
0
 public virtual void Initialize(ShapeableExpando extensions, object target)
 {
 }