public object RecreateClassProxy(SerializationInfo info, StreamingContext context)
        {
            bool delegateBaseSer = info.GetBoolean("__delegateToBase");

            if (!delegateBaseSer)
            {
                _data = (object[])info.GetValue("__data", typeof(object[]));
            }

            object proxy = null;

            GeneratorContext genContext = new GeneratorContext();

            if (_mixins.Length != 0)
            {
                foreach (object mixin in _mixins)
                {
                    genContext.AddMixinInstance(mixin);
                }
            }

            ClassProxyGenerator cpGen = new ClassProxyGenerator(_scope, genContext);

            Type proxy_type;

            if (_mixins.Length == 0)
            {
                proxy_type = cpGen.GenerateCode(_baseType, _interfaces);
            }
            else
            {
                proxy_type = cpGen.GenerateCustomCode(_baseType, _interfaces);
            }

            if (delegateBaseSer)
            {
                proxy = Activator.CreateInstance(proxy_type, new object[] { info, context });
            }
            else
            {
                if (_mixins.Length == 0)
                {
                    proxy = Activator.CreateInstance(proxy_type, new object[] { _interceptor });
                }
                else
                {
                    ArrayList args = new ArrayList();
                    args.Add(_interceptor);
                    args.Add(genContext.MixinsAsArray());

                    proxy = Activator.CreateInstance(proxy_type, args.ToArray());
                }

                MemberInfo[] members = FormatterServices.GetSerializableMembers(_baseType);
                FormatterServices.PopulateObjectMembers(proxy, members, _data);
            }

            return(proxy);
        }
        protected override void CustomizeProxy(object proxy, GeneratorContext context, IKernel kernel, ComponentModel model)
        {
            object[] mixins = context.MixinsAsArray();

            for (int i = 0; i < mixins.Length; i++)
            {
                object mixin = mixins[i];

                if (mixin is IProxyAware)
                {
                    (mixin as IProxyAware).SetProxy(proxy);
                }
            }
        }
        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);
        }
Beispiel #4
0
		public object RecreateInterfaceProxy(SerializationInfo info, StreamingContext context)
		{
			object proxy = null;

			GeneratorContext genContext = new GeneratorContext();

			foreach(object mixin in _mixins)
			{
				genContext.AddMixinInstance(mixin);
			}

			InterfaceProxyGenerator gen = new InterfaceProxyGenerator( _scope, genContext );

			object target = info.GetValue("__target", typeof(object));

			if (_mixins.Length == 0)
			{
				Type proxy_type = gen.GenerateCode( _interfaces, target.GetType());

				proxy = Activator.CreateInstance( proxy_type, new object[] { _interceptor, target } );
			}
			else
			{
				Type proxy_type = gen.GenerateCode( _interfaces, target.GetType() );

				proxy = Activator.CreateInstance( proxy_type, new object[] { _interceptor, target, genContext.MixinsAsArray() } );
			}

			return proxy;
		}
Beispiel #5
0
		public object RecreateClassProxy(SerializationInfo info, StreamingContext context)
		{
			bool delegateBaseSer = info.GetBoolean("__delegateToBase");

			if (!delegateBaseSer)
			{
				_data = (object[]) info.GetValue("__data", typeof(object[]) );
			}

			object proxy = null;

			GeneratorContext genContext = new GeneratorContext();
			
			if (_mixins.Length != 0)
			{
				foreach(object mixin in _mixins)
				{
					genContext.AddMixinInstance(mixin);
				}
			}

			ClassProxyGenerator cpGen = new ClassProxyGenerator( _scope, genContext );

			Type proxy_type;

			if (_mixins.Length == 0)
			{
				proxy_type = cpGen.GenerateCode( _baseType, _interfaces );
			}
			else
			{
				proxy_type = cpGen.GenerateCustomCode( _baseType, _interfaces );
			}

			if (delegateBaseSer)
			{
				proxy = Activator.CreateInstance( proxy_type, new object[] { info, context } );
			}
			else
			{
				if (_mixins.Length == 0)
				{
					proxy = Activator.CreateInstance( proxy_type, new object[] { _interceptor } );
				}
				else
				{
					ArrayList args = new ArrayList();
					args.Add(_interceptor);
					args.Add(genContext.MixinsAsArray());
					
					proxy = Activator.CreateInstance( proxy_type, args.ToArray() );
				}

				MemberInfo[] members = FormatterServices.GetSerializableMembers( _baseType );
				FormatterServices.PopulateObjectMembers(proxy, members, _data);
			}

			return proxy;
		}
        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() }));
        }
        public object RecreateInterfaceProxy(SerializationInfo info, StreamingContext context)
        {
            object proxy = null;

            GeneratorContext genContext = new GeneratorContext();

            foreach (object mixin in _mixins)
            {
                genContext.AddMixinInstance(mixin);
            }

            InterfaceProxyGenerator gen = new InterfaceProxyGenerator(_scope, genContext);

            object target = info.GetValue("__target", typeof(object));

            if (_mixins.Length == 0)
            {
                Type proxy_type = gen.GenerateCode(_interfaces, target.GetType());

                proxy = Activator.CreateInstance(proxy_type, new object[] { _interceptor, target });
            }
            else
            {
                Type proxy_type = gen.GenerateCode(_interfaces, target.GetType());

                proxy = Activator.CreateInstance(proxy_type, new object[] { _interceptor, target, genContext.MixinsAsArray() });
            }

            return(proxy);
        }