예제 #1
0
        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);
        }
예제 #2
0
        public virtual Type CreateCustomClassProxy(Type theClass, GeneratorContext context)
        {
            ClassProxyGenerator generator = new ClassProxyGenerator(this._scope, context);

            return(generator.GenerateCustomCode(theClass, null));
        }