Exemple #1
0
 protected virtual object CreateCustomClassProxyInstance(Type type, IInterceptor interceptor, GeneratorContext context, params object[] argumentsForConstructor)
 {
     if (context.HasMixins)
     {
         ArrayList list = new ArrayList();
         list.Add(interceptor);
         list.Add(context.MixinsAsArray());
         list.AddRange(argumentsForConstructor);
         return(Activator.CreateInstance(type, list.ToArray()));
     }
     return(this.CreateClassProxyInstance(type, interceptor, argumentsForConstructor));
 }
        public object RecreateClassProxy(SerializationInfo info, StreamingContext context)
        {
            Type type;
            bool boolean = info.GetBoolean("__delegateToBase");

            if (!boolean)
            {
                this._data = (object[])info.GetValue("__data", typeof(object[]));
            }
            object           obj2     = null;
            GeneratorContext context2 = new GeneratorContext();

            if (this._mixins.Length != 0)
            {
                foreach (object obj3 in this._mixins)
                {
                    context2.AddMixinInstance(obj3);
                }
            }
            ClassProxyGenerator generator = new ClassProxyGenerator(_scope, context2);

            if (this._mixins.Length == 0)
            {
                type = generator.GenerateCode(this._baseType, this._interfaces);
            }
            else
            {
                type = generator.GenerateCustomCode(this._baseType, this._interfaces);
            }
            if (boolean)
            {
                return(Activator.CreateInstance(type, new object[] { info, context }));
            }
            if (this._mixins.Length == 0)
            {
                obj2 = Activator.CreateInstance(type, new object[] { this._interceptor });
            }
            else
            {
                ArrayList list = new ArrayList();
                list.Add(this._interceptor);
                list.Add(context2.MixinsAsArray());
                obj2 = Activator.CreateInstance(type, list.ToArray());
            }
            MemberInfo[] serializableMembers = FormatterServices.GetSerializableMembers(this._baseType);
            FormatterServices.PopulateObjectMembers(obj2, serializableMembers, this._data);
            return(obj2);
        }
        public object RecreateInterfaceProxy(SerializationInfo info, StreamingContext context)
        {
            GeneratorContext context2 = new GeneratorContext();

            foreach (object obj3 in this._mixins)
            {
                context2.AddMixinInstance(obj3);
            }
            InterfaceProxyGenerator generator = new InterfaceProxyGenerator(_scope, context2);
            object obj4 = info.GetValue("__target", typeof(object));

            if (this._mixins.Length == 0)
            {
                return(Activator.CreateInstance(generator.GenerateCode(this._interfaces, obj4.GetType()), new object[] { this._interceptor, obj4 }));
            }
            return(Activator.CreateInstance(generator.GenerateCode(this._interfaces, obj4.GetType()), new object[] { this._interceptor, obj4, context2.MixinsAsArray() }));
        }
Exemple #4
0
 protected virtual object CreateCustomProxyInstance(Type type, IInterceptor interceptor, object target, GeneratorContext context)
 {
     if (context.HasMixins)
     {
         return(Activator.CreateInstance(type, new object[] { interceptor, target, context.MixinsAsArray() }));
     }
     return(this.CreateProxyInstance(type, interceptor, target));
 }