public object GetRealObject(StreamingContext context)
        {
            var tInterfaces = Interfaces ?? MonoInterfaces.Select(it => Type.GetType(it)).ToArray();
            var tType       = BuildProxy.BuildType(Context, tInterfaces.First(), tInterfaces.Skip(1).ToArray());

            return(Impromptu.InitializeProxy(tType, Original, tInterfaces));
        }
Example #2
0
        public object GetRealObject(StreamingContext context)
        {
            var interfaces = Interfaces ?? MonoInterfaces.Select(it => Type.GetType(it)).ToArray();
            var type       = BuildProxy.BuildType(Context, interfaces.First(), interfaces.Skip(1).ToArray());

            return(InvocationBinding.InitializeProxy(type, Original, interfaces));
        }
Example #3
0
        /// <summary>
        /// Static Method that wraps an existing dynamic object with a explicit interface type
        /// </summary>
        /// <param name="originalDynamic">The original dynamic.</param>
        /// <param name="otherInterfaces">The other interfaces.</param>
        /// <returns></returns>
        public static dynamic DynamicActLike(object originalDynamic, params Type[] otherInterfaces)
        {
            Type tContext;
            bool tDummy;

            originalDynamic = originalDynamic.GetTargetContext(out tContext, out tDummy);
            tContext        = tContext.FixContext();

            var tProxy = BuildProxy.BuildType(tContext, otherInterfaces.First(), otherInterfaces.Skip(1).ToArray());

            return(InitializeProxy(tProxy, originalDynamic, otherInterfaces));
        }
        public static dynamic DynamicDressedAs(object originalDynamic, params Type[] otherInterfaces)
        {
            Type tContext;
            bool tDummy;

            originalDynamic = originalDynamic.GetInvocationContext(out tContext, out tDummy);
            tContext        = tContext.MaybeDetectArrayContext();

            var tProxy = BuildProxy.BuildType(tContext, otherInterfaces.First(), otherInterfaces.Skip(1).ToArray());

            return(InitializeProxy(tProxy, originalDynamic, otherInterfaces));
        }
Example #5
0
        /// <summary>
        ///   Makes static methods for the passed in property spec, designed to be used with old api's that reflect properties.
        /// </summary>
        /// <param name="originalDynamic"> The original dynamic. </param>
        /// <param name="propertySpec"> The property spec. </param>
        /// <returns> </returns>
        public static dynamic ActLikeProperties(this object originalDynamic, IDictionary <string, Type> propertySpec)
        {
            Type tContext;
            bool tDummy;

            originalDynamic = originalDynamic.GetTargetContext(out tContext, out tDummy);
            tContext        = tContext.FixContext();

            var tProxy = BuildProxy.BuildType(tContext, propertySpec);

            return
                (InitializeProxy(tProxy, originalDynamic, propertySpec: propertySpec));
        }
        public static dynamic SelectProperties(this object originalDynamic, IDictionary <string, Type> propertySpec)
        {
            Type context;
            bool _;

            originalDynamic = originalDynamic.GetInvocationContext(out context, out _);
            context         = context.MaybeDetectArrayContext();

            var tProxy = BuildProxy.BuildType(context, propertySpec);

            return
                (InitializeProxy(tProxy, originalDynamic, propertySpec: propertySpec));
        }
Example #7
0
        public object GetRealObject(StreamingContext context)
        {
            var tInterfaces = Interfaces;

            if (tInterfaces == null)
            {
                throw new InvalidOperationException("Expected SerializationData to contain a non-null Interfaces field. Please consider upgrading mono!");
            }

            var tType = BuildProxy.BuildType(Context, tInterfaces.First(), tInterfaces.Skip(1).ToArray());

            return(Impromptu.InitializeProxy(tType, Original, tInterfaces));
        }
Example #8
0
        /// <summary>
        ///   Extension Method that Wraps an existing object with an Explicit interface definition
        /// </summary>
        /// <typeparam name="TInterface"> The type of the interface. </typeparam>
        /// <param name="originalDynamic"> The original object can be annoymous type, System.DynamicObject as well as any others. </param>
        /// <param name="otherInterfaces"> Optional other interfaces. </param>
        /// <returns> </returns>
        public static TInterface ActLike <TInterface>(this object originalDynamic, params Type[] otherInterfaces) where TInterface : class
        {
            Type tContext;
            bool tDummy;

            originalDynamic = originalDynamic.GetTargetContext(out tContext, out tDummy);
            tContext        = tContext.FixContext();

            var tProxy = BuildProxy.BuildType(tContext, typeof(TInterface), otherInterfaces);

            return
                ((TInterface)
                 InitializeProxy(tProxy, originalDynamic, new[] { typeof(TInterface) }.Concat(otherInterfaces)));
        }
        public static TInterface DressedAs <TInterface>(this object originalDynamic, params Type[] otherInterfaces)
            where TInterface : class
        {
            Type context;
            bool _;

            originalDynamic = originalDynamic.GetInvocationContext(out context, out _);
            context         = context.MaybeDetectArrayContext();

            var proxy = BuildProxy.BuildType(context, typeof(TInterface), otherInterfaces);

            return
                ((TInterface)
                 InitializeProxy(proxy, originalDynamic, new[] { typeof(TInterface) }.Concat(otherInterfaces)));
        }