示例#1
0
 internal void Init(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, string assemblyName)
 {
     this.objectType         = objectType;
     this.objectManager      = objectManager;
     this.context            = context;
     this.serObjectInfoInit  = serObjectInfoInit;
     this.formatterConverter = converter;
     this.InitReadConstructor(objectType, surrogateSelector, context, assemblyName);
 }
示例#2
0
        // Write Constructor used for array types or null members
        internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {
            InternalST.Soap(this, objectInfoId, " Constructor 2 ", objectType);

            this.objectType                = objectType;
            this.context                   = context;
            this.serObjectInfoInit         = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;
            this.surrogateSelector         = surrogateSelector;
            this.converter                 = converter;

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo   = GetTypeAttributeInfo();
                InitNoMembers();
                return;
            }

            typeAttributeInfo = GetTypeAttributeInfo();

            ISurrogateSelector surrogateSelectorTemp = null;

            if (surrogateSelector != null)
            {
                serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);
            }

            if (serializationSurrogate != null)
            {
                isSi = true;
            }
            else if (objectType == Converter.typeofObject)
            {
            }
            else if (Converter.typeofISerializable.IsAssignableFrom(objectType))
            {
                isSi = true;
            }

            if (isSi)
            {
                si    = new SerializationInfo(objectType, converter);
                cache = new SerObjectInfoCache();
                cache.fullTypeName   = si.FullTypeName;
                cache.assemblyString = si.AssemblyName;
            }
            else
            {
                InitMemberInfo();
            }

            InternalST.Soap(this, objectInfoId, " ", objectType, " InitSerialize Exit ", isSi);
        }
 private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
 {
     WriteObjectInfo info = null;
     if (!serObjectInfoInit.oiPool.IsEmpty())
     {
         info = (WriteObjectInfo) serObjectInfoInit.oiPool.Pop();
         info.InternalInit();
         return info;
     }
     return new WriteObjectInfo { objectInfoId = serObjectInfoInit.objectInfoIdCount++ };
 }
 internal void InitSerialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
 {
     this.context                   = context;
     this.obj                       = obj;
     this.serObjectInfoInit         = serObjectInfoInit;
     this.parentMemberAttributeInfo = attributeInfo;
     this.surrogateSelector         = surrogateSelector;
     this.converter                 = converter;
     if (RemotingServices.IsTransparentProxy(obj))
     {
         this.objectType = Converter.typeofMarshalByRefObject;
     }
     else
     {
         this.objectType = obj.GetType();
     }
     if (this.objectType.IsArray)
     {
         this.arrayElemObjectInfo = Serialize(this.objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
         this.typeAttributeInfo   = this.GetTypeAttributeInfo();
         this.isArray             = true;
         this.InitNoMembers();
     }
     else
     {
         ISurrogateSelector selector;
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         objectWriter.ObjectManager.RegisterObject(obj);
         if ((surrogateSelector != null) && ((this.serializationSurrogate = surrogateSelector.GetSurrogate(this.objectType, context, out selector)) != null))
         {
             this.si = new SerializationInfo(this.objectType, converter);
             if (!this.objectType.IsPrimitive)
             {
                 this.serializationSurrogate.GetObjectData(obj, this.si, context);
             }
             this.InitSiWrite(objectWriter);
         }
         else if (obj is ISerializable)
         {
             if (!this.objectType.IsSerializable)
             {
                 throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NonSerType"), new object[] { this.objectType.FullName, this.objectType.Module.Assembly.FullName }));
             }
             this.si = new SerializationInfo(this.objectType, converter);
             ((ISerializable)obj).GetObjectData(this.si, context);
             this.InitSiWrite(objectWriter);
         }
         else
         {
             this.InitMemberInfo();
         }
     }
 }
示例#5
0
        private static ReadObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
        {
            ReadObjectInfo info = null;

            if (!serObjectInfoInit.oiPool.IsEmpty())
            {
                info = (ReadObjectInfo)serObjectInfoInit.oiPool.Pop();
                info.InternalInit();
                return(info);
            }
            return(new ReadObjectInfo {
                objectInfoId = serObjectInfoInit.objectInfoIdCount++
            });
        }
示例#6
0
 internal void Init(Type objectType, string[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, string assemblyName)
 {
     this.objectType         = objectType;
     this.objectManager      = objectManager;
     this.wireMemberNames    = memberNames;
     this.wireMemberTypes    = memberTypes;
     this.context            = context;
     this.serObjectInfoInit  = serObjectInfoInit;
     this.formatterConverter = converter;
     if (memberNames != null)
     {
         this.isNamed = true;
     }
     if (memberTypes != null)
     {
         this.isTyped = true;
     }
     this.InitReadConstructor(objectType, surrogateSelector, context, assemblyName);
 }
 internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
 {
     this.objectType                = objectType;
     this.context                   = context;
     this.serObjectInfoInit         = serObjectInfoInit;
     this.parentMemberAttributeInfo = attributeInfo;
     this.surrogateSelector         = surrogateSelector;
     this.converter                 = converter;
     if (objectType.IsArray)
     {
         this.arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
         this.typeAttributeInfo   = this.GetTypeAttributeInfo();
         this.InitNoMembers();
     }
     else
     {
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         ISurrogateSelector selector = null;
         if (surrogateSelector != null)
         {
             this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector);
         }
         if (this.serializationSurrogate != null)
         {
             this.isSi = true;
         }
         else if (!(objectType == Converter.typeofObject) && Converter.typeofISerializable.IsAssignableFrom(objectType))
         {
             this.isSi = true;
         }
         if (this.isSi)
         {
             this.si    = new SerializationInfo(objectType, converter);
             this.cache = new SerObjectInfoCache();
             this.cache.fullTypeName   = this.si.FullTypeName;
             this.cache.assemblyString = this.si.AssemblyName;
         }
         else
         {
             this.InitMemberInfo();
         }
     }
 }
示例#8
0
        private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
        {
            WriteObjectInfo objectInfo = null;

            if (!serObjectInfoInit.oiPool.IsEmpty())
            {
                objectInfo = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop();
                objectInfo.InternalInit();
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo from pool");
            }
            else
            {
                objectInfo = new WriteObjectInfo();
                objectInfo.objectInfoId = serObjectInfoInit.objectInfoIdCount++;
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo new not from pool");
            }

            return(objectInfo);
        }
 internal void Serialize(object graph, Header[] inHeaders, SoapWriter serWriter)
 {
     object obj2;
     long num2;
     bool flag;
     serializationPermission.Demand();
     if (graph == null)
     {
         throw new ArgumentNullException("graph", SoapUtil.GetResourceString("ArgumentNull_Graph"));
     }
     if (serWriter == null)
     {
         throw new ArgumentNullException("serWriter", string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("ArgumentNull_WithParamName"), new object[] { "serWriter" }));
     }
     this.serObjectInfoInit = new SerObjectInfoInit();
     this.serWriter = serWriter;
     this.headers = inHeaders;
     if (graph is IMethodMessage)
     {
         this.bRemoting = true;
         MethodBase methodBase = ((IMethodMessage) graph).MethodBase;
         if (methodBase != null)
         {
             serWriter.WriteXsdVersion(this.ProcessTypeAttributes(methodBase.ReflectedType));
         }
         else
         {
             serWriter.WriteXsdVersion(XsdVersion.V2001);
         }
     }
     else
     {
         serWriter.WriteXsdVersion(XsdVersion.V2001);
     }
     this.m_idGenerator = new ObjectIDGenerator();
     this.m_objectQueue = new Queue();
     if (graph is ISoapMessage)
     {
         this.bRemoting = true;
         ISoapMessage message = (ISoapMessage) graph;
         graph = new InternalSoapMessage(message.MethodName, message.XmlNameSpace, message.ParamNames, message.ParamValues, message.ParamTypes);
         this.headers = message.Headers;
     }
     this.m_serializedTypeTable = new Hashtable();
     serWriter.WriteBegin();
     long headerId = 0L;
     this.topId = this.m_idGenerator.GetId(graph, out flag);
     if (this.headers != null)
     {
         headerId = this.m_idGenerator.GetId(this.headers, out flag);
     }
     else
     {
         headerId = -1L;
     }
     this.WriteSerializedStreamHeader(this.topId, headerId);
     if ((this.headers != null) && (this.headers.Length != 0))
     {
         this.ProcessHeaders(headerId);
     }
     this.m_objectQueue.Enqueue(graph);
     while ((obj2 = this.GetNext(out num2)) != null)
     {
         WriteObjectInfo objectInfo = null;
         if (obj2 is WriteObjectInfo)
         {
             objectInfo = (WriteObjectInfo) obj2;
         }
         else
         {
             objectInfo = WriteObjectInfo.Serialize(obj2, this.m_surrogates, this.m_context, this.serObjectInfoInit, this.m_formatterConverter, null, this);
             objectInfo.assemId = this.GetAssemblyId(objectInfo);
         }
         objectInfo.objectId = num2;
         NameInfo memberNameInfo = this.TypeToNameInfo(objectInfo);
         memberNameInfo.NIisTopLevelObject = true;
         if (this.bRemoting && (obj2 == graph))
         {
             memberNameInfo.NIisRemoteRecord = true;
         }
         this.Write(objectInfo, memberNameInfo, memberNameInfo);
         this.PutNameInfo(memberNameInfo);
         objectInfo.ObjectEnd();
     }
     serWriter.WriteSerializationHeaderEnd();
     serWriter.WriteEnd();
     this.m_idGenerator = new ObjectIDGenerator();
     this.m_serializedTypeTable = new Hashtable();
     this.m_objectManager.RaiseOnSerializedEvent();
 }
示例#10
0
        internal static ReadObjectInfo Create(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, String assemblyName)
        {
            ReadObjectInfo soi = GetObjectInfo(serObjectInfoInit);

            soi.Init(objectType, memberNames, memberTypes, surrogateSelector, context, objectManager, serObjectInfoInit, converter, assemblyName);
            return(soi);
        }
示例#11
0
 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
     //InternalST.Soap( "PutObjectInfo",objectInfo.objectInfoId," PutObjectInfo to pool");
 }
示例#12
0
 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
     //InternalST.Soap( "PutObjectInfo",objectInfo.objectInfoId," PutObjectInfo to pool");							
 }
 internal static ReadObjectInfo Create(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, string assemblyName)
 {
     ReadObjectInfo objectInfo = GetObjectInfo(serObjectInfoInit);
     objectInfo.Init(objectType, surrogateSelector, context, objectManager, serObjectInfoInit, converter, assemblyName);
     return objectInfo;
 }
示例#14
0
 internal static ReadObjectInfo Create(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, String assemblyName)
 {
     ReadObjectInfo soi = GetObjectInfo(serObjectInfoInit);                      
     soi.Init(objectType, memberNames,memberTypes, surrogateSelector, context, objectManager, serObjectInfoInit, converter, assemblyName);
     return soi;
 }
示例#15
0
        // Write Constructor used for array types or null members
        internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {

            InternalST.Soap( this, objectInfoId," Constructor 2 ",objectType);     

            this.objectType = objectType;
            this.context = context;
            this.serObjectInfoInit = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;         
            this.surrogateSelector = surrogateSelector;
            this.converter = converter;

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo = GetTypeAttributeInfo();
                InitNoMembers();
                return;         
            }

            typeAttributeInfo = GetTypeAttributeInfo();

            ISurrogateSelector surrogateSelectorTemp = null;

            if (surrogateSelector!=null)
                serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);

            if (serializationSurrogate != null)
            {
                isSi = true;
            }
            else if (objectType == Converter.typeofObject)
            {
            }
            else if (Converter.typeofISerializable.IsAssignableFrom(objectType))
                isSi = true;

            if (isSi)
            {
                si = new SerializationInfo(objectType, converter);
                cache = new SerObjectInfoCache();
                cache.fullTypeName = si.FullTypeName;
                cache.assemblyString = si.AssemblyName;
            }
            else
            {
                InitMemberInfo();
            }

            InternalST.Soap( this,objectInfoId," ", objectType," InitSerialize Exit ",isSi);       
        }
 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, WriteObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
 }
 internal static WriteObjectInfo Serialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
 {
     WriteObjectInfo objectInfo = GetObjectInfo(serObjectInfoInit);
     objectInfo.InitSerialize(obj, surrogateSelector, context, serObjectInfoInit, converter, attributeInfo, objectWriter);
     return objectInfo;
 }
 internal void InitSerialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
 {
     this.context = context;
     this.obj = obj;
     this.serObjectInfoInit = serObjectInfoInit;
     this.parentMemberAttributeInfo = attributeInfo;
     this.surrogateSelector = surrogateSelector;
     this.converter = converter;
     if (RemotingServices.IsTransparentProxy(obj))
     {
         this.objectType = Converter.typeofMarshalByRefObject;
     }
     else
     {
         this.objectType = obj.GetType();
     }
     if (this.objectType.IsArray)
     {
         this.arrayElemObjectInfo = Serialize(this.objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         this.isArray = true;
         this.InitNoMembers();
     }
     else
     {
         ISurrogateSelector selector;
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         objectWriter.ObjectManager.RegisterObject(obj);
         if ((surrogateSelector != null) && ((this.serializationSurrogate = surrogateSelector.GetSurrogate(this.objectType, context, out selector)) != null))
         {
             this.si = new SerializationInfo(this.objectType, converter);
             if (!this.objectType.IsPrimitive)
             {
                 this.serializationSurrogate.GetObjectData(obj, this.si, context);
             }
             this.InitSiWrite(objectWriter);
         }
         else if (obj is ISerializable)
         {
             if (!this.objectType.IsSerializable)
             {
                 throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NonSerType"), new object[] { this.objectType.FullName, this.objectType.Module.Assembly.FullName }));
             }
             this.si = new SerializationInfo(this.objectType, converter);
             ((ISerializable) obj).GetObjectData(this.si, context);
             this.InitSiWrite(objectWriter);
         }
         else
         {
             this.InitMemberInfo();
         }
     }
 }
 internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
 {
     this.objectType = objectType;
     this.context = context;
     this.serObjectInfoInit = serObjectInfoInit;
     this.parentMemberAttributeInfo = attributeInfo;
     this.surrogateSelector = surrogateSelector;
     this.converter = converter;
     if (objectType.IsArray)
     {
         this.arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         this.InitNoMembers();
     }
     else
     {
         this.typeAttributeInfo = this.GetTypeAttributeInfo();
         ISurrogateSelector selector = null;
         if (surrogateSelector != null)
         {
             this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector);
         }
         if (this.serializationSurrogate != null)
         {
             this.isSi = true;
         }
         else if (!(objectType == Converter.typeofObject) && Converter.typeofISerializable.IsAssignableFrom(objectType))
         {
             this.isSi = true;
         }
         if (this.isSi)
         {
             this.si = new SerializationInfo(objectType, converter);
             this.cache = new SerObjectInfoCache();
             this.cache.fullTypeName = this.si.FullTypeName;
             this.cache.assemblyString = this.si.AssemblyName;
         }
         else
         {
             this.InitMemberInfo();
         }
     }
 }
示例#20
0
        // Deserialize the stream into an object graph.
        internal Object Deserialize(HeaderHandler handler, ISerParser serParser)
        {

            InternalST.Soap( this, "Deserialize Entry handler", handler);

            if (serParser == null)
                throw new ArgumentNullException("serParser", String.Format(SoapUtil.GetResourceString("ArgumentNull_WithParamName"), serParser));


            deserializationSecurityException = null;
            try {
                serializationPermission.Demand();
            } catch(Exception e ) {
                deserializationSecurityException = e;
            }

            this.handler = handler;
            isTopObjectSecondPass = false;
            isHeaderHandlerCalled = false;

            if (handler != null)
                IsFakeTopObject = true;

            m_idGenerator = new ObjectIDGenerator();


            m_objectManager = GetObjectManager();

            serObjectInfoInit = new SerObjectInfoInit();
            objectIdTable.Clear();
            objectIds = 0;

            // Will call back to ParseObject, ParseHeader for each object found
            serParser.Run();

            if (handler != null)
            {
                InternalST.Soap( this, "Deserialize Fixup Before Delegate Invoke");         
                m_objectManager.DoFixups(); // Fixup for headers

                // Header handler isn't invoked until method name is known from body fake record
                // Except for SoapFault, in which case it is invoked below
                if (handlerObject == null)
                {
                    InternalST.Soap( this, "Deserialize Before SoapFault Delegate Invoke ");
                    handlerObject = handler(newheaders);
                    InternalST.Soap( this, "Deserialize after SoapFault Delegate Invoke");
                }


                // SoapFault creation Create a fake Pr for the handlerObject to use.
                // Create a member for the fake pr with name __fault;
                if ((soapFaultId > 0) && (handlerObject != null))
                {
                    InternalST.Soap( this, "Deserialize SoapFault ");
                    topStack = new SerStack("Top ParseRecords");                
                    ParseRecord pr = new ParseRecord();
                    pr.PRparseTypeEnum = InternalParseTypeE.Object;
                    pr.PRobjectPositionEnum = InternalObjectPositionE.Top;
                    pr.PRparseStateEnum = InternalParseStateE.Object;
                    pr.PRname = "Response";
                    topStack.Push(pr);
                    pr = new ParseRecord();
                    pr.PRparseTypeEnum = InternalParseTypeE.Member;
                    pr.PRobjectPositionEnum = InternalObjectPositionE.Child;
                    pr.PRmemberTypeEnum = InternalMemberTypeE.Field;
                    pr.PRmemberValueEnum = InternalMemberValueE.Reference;
                    pr.PRparseStateEnum = InternalParseStateE.Member;
                    pr.PRname = "__fault";
                    pr.PRidRef = soapFaultId;
                    topStack.Push(pr);
                    pr = new ParseRecord();
                    pr.PRparseTypeEnum = InternalParseTypeE.ObjectEnd;
                    pr.PRobjectPositionEnum = InternalObjectPositionE.Top;
                    pr.PRparseStateEnum = InternalParseStateE.Object;
                    pr.PRname = "Response";
                    topStack.Push(pr);
                    isTopObjectResolved = false;
                }
            }


            // Resolve fake top object if necessary
            if (!isTopObjectResolved)
            {
                //resolve top object
                InternalST.Soap( this, "Deserialize TopObject Second Pass");                
                isTopObjectSecondPass = true;
                topStack.Reverse();
                // The top of the stack now contains the fake record
                // When it is Parsed, the handler object will be substituted
                // for it in ParseObject.
                int topStackLength = topStack.Count();
                ParseRecord pr = null;
                for (int i=0; i<topStackLength; i++)
                {
                    pr = (ParseRecord)topStack.Pop();
                    Parse(pr);
                }
            }


            InternalST.Soap( this, "Deserialize Finished Parsing DoFixups");

            m_objectManager.DoFixups();

            if (topObject == null)
                throw new SerializationException(SoapUtil.GetResourceString("Serialization_TopObject"));

            if (topObject is IObjectReference) {
                topObject = ((IObjectReference)topObject).GetRealObject(m_context);
            }       

            InternalST.Soap( this, "Deserialize Exit ",topObject);

            m_objectManager.RaiseDeserializationEvent();

            if ((formatterEnums.FEtopObject != null) &&
                  (topObject is InternalSoapMessage))


            {
                // Convert InternalSoapMessage to SoapMessage           
                InternalST.Soap( this, "Deserialize SoapMessage Entry ");           

                InternalSoapMessage ismc = (InternalSoapMessage)topObject;
                ISoapMessage smc = (ISoapMessage)formatterEnums.FEtopObject;
                smc.MethodName = ismc.methodName;
                smc.XmlNameSpace = ismc.xmlNameSpace;
                smc.ParamNames = ismc.paramNames;
                smc.ParamValues = ismc.paramValues;
                smc.Headers = headers;
                topObject = smc;
                isTopObjectResolved = true;
                InternalST.Soap( this, "Deserialize SoapMessage Exit topObject ",topObject," method name ",smc.MethodName);                         
            }

            return topObject;
        }
示例#21
0
        // Write constructor
        internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {
            InternalST.Soap( this, objectInfoId," Constructor 1 ",obj);        
            this.context = context;
            this.obj = obj;
            this.serObjectInfoInit = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;
            this.surrogateSelector = surrogateSelector;
            this.converter = converter;
            ISurrogateSelector surrogateSelectorTemp;

            if (RemotingServices.IsTransparentProxy(obj))
                objectType = Converter.typeofMarshalByRefObject;
            else
                objectType = obj.GetType();

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo = GetTypeAttributeInfo();
                isArray = true;
                InitNoMembers();
                return;
            }

            InternalST.Soap( this, objectInfoId," Constructor 1 trace 2");

            typeAttributeInfo = GetTypeAttributeInfo();

            if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null)
            {
                InternalST.Soap( this, objectInfoId," Constructor 1 trace 3");         
                si = new SerializationInfo(objectType, converter);
                if (!objectType.IsPrimitive)
                    serializationSurrogate.GetObjectData(obj, si, context);
                InitSiWrite();
            }
            else if (obj is ISerializable)
            {
                if (!objectType.IsSerializable)
                {
                    throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_NonSerType"), 
                                                                   objectType.FullName, objectType.Module.Assembly.FullName));
                }
                si = new SerializationInfo(objectType, converter);
                ((ISerializable)obj).GetObjectData(si, context);
                InternalST.Soap( this, objectInfoId," Constructor 1 trace 4 ISerializable "+objectType);                       
                InitSiWrite();
            }
            else
            {
                InternalST.Soap(this, objectInfoId," Constructor 1 trace 5");
                InitMemberInfo();
            }
        }
 internal object Deserialize(HeaderHandler handler, ISerParser serParser)
 {
     if (serParser == null)
     {
         throw new ArgumentNullException("serParser", string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("ArgumentNull_WithParamName"), new object[] { serParser }));
     }
     this.deserializationSecurityException = null;
     try
     {
         serializationPermission.Demand();
     }
     catch (Exception exception)
     {
         this.deserializationSecurityException = exception;
     }
     this.handler = handler;
     this.isTopObjectSecondPass = false;
     this.isHeaderHandlerCalled = false;
     if (handler != null)
     {
         this.IsFakeTopObject = true;
     }
     this.m_idGenerator = new ObjectIDGenerator();
     this.m_objectManager = this.GetObjectManager();
     this.serObjectInfoInit = new SerObjectInfoInit();
     this.objectIdTable.Clear();
     this.objectIds = 0L;
     serParser.Run();
     if (handler != null)
     {
         this.m_objectManager.DoFixups();
         if (this.handlerObject == null)
         {
             this.handlerObject = handler(this.newheaders);
         }
         if ((this.soapFaultId > 0L) && (this.handlerObject != null))
         {
             this.topStack = new SerStack("Top ParseRecords");
             ParseRecord record = new ParseRecord {
                 PRparseTypeEnum = InternalParseTypeE.Object,
                 PRobjectPositionEnum = InternalObjectPositionE.Top,
                 PRparseStateEnum = InternalParseStateE.Object,
                 PRname = "Response"
             };
             this.topStack.Push(record);
             record = new ParseRecord {
                 PRparseTypeEnum = InternalParseTypeE.Member,
                 PRobjectPositionEnum = InternalObjectPositionE.Child,
                 PRmemberTypeEnum = InternalMemberTypeE.Field,
                 PRmemberValueEnum = InternalMemberValueE.Reference,
                 PRparseStateEnum = InternalParseStateE.Member,
                 PRname = "__fault",
                 PRidRef = this.soapFaultId
             };
             this.topStack.Push(record);
             record = new ParseRecord {
                 PRparseTypeEnum = InternalParseTypeE.ObjectEnd,
                 PRobjectPositionEnum = InternalObjectPositionE.Top,
                 PRparseStateEnum = InternalParseStateE.Object,
                 PRname = "Response"
             };
             this.topStack.Push(record);
             this.isTopObjectResolved = false;
         }
     }
     if (!this.isTopObjectResolved)
     {
         this.isTopObjectSecondPass = true;
         this.topStack.Reverse();
         int num = this.topStack.Count();
         ParseRecord pr = null;
         for (int i = 0; i < num; i++)
         {
             pr = (ParseRecord) this.topStack.Pop();
             this.Parse(pr);
         }
     }
     this.m_objectManager.DoFixups();
     if (this.topObject == null)
     {
         throw new SerializationException(SoapUtil.GetResourceString("Serialization_TopObject"));
     }
     if (this.HasSurrogate(this.topObject.GetType()) && (this.topId != 0L))
     {
         this.topObject = this.m_objectManager.GetObject(this.topId);
     }
     if (this.topObject is IObjectReference)
     {
         this.topObject = ((IObjectReference) this.topObject).GetRealObject(this.m_context);
     }
     this.m_objectManager.RaiseDeserializationEvent();
     if ((this.formatterEnums.FEtopObject != null) && (this.topObject is InternalSoapMessage))
     {
         InternalSoapMessage topObject = (InternalSoapMessage) this.topObject;
         ISoapMessage fEtopObject = this.formatterEnums.FEtopObject;
         fEtopObject.MethodName = topObject.methodName;
         fEtopObject.XmlNameSpace = topObject.xmlNameSpace;
         fEtopObject.ParamNames = topObject.paramNames;
         fEtopObject.ParamValues = topObject.paramValues;
         fEtopObject.Headers = this.headers;
         this.topObject = fEtopObject;
         this.isTopObjectResolved = true;
     }
     return this.topObject;
 }
示例#23
0
 internal static WriteObjectInfo Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
 {
     WriteObjectInfo soi = GetObjectInfo(serObjectInfoInit);         
     soi.InitSerialize(objectType, surrogateSelector, context, serObjectInfoInit, converter, attributeInfo);
     return soi;         
 }
示例#24
0
 private static void PutObjectInfo(SerObjectInfoInit serObjectInfoInit, ReadObjectInfo objectInfo)
 {
     serObjectInfoInit.oiPool.Push(objectInfo);
 }
示例#25
0
        private static WriteObjectInfo GetObjectInfo(SerObjectInfoInit serObjectInfoInit)
        {
            WriteObjectInfo objectInfo = null;

            if (!serObjectInfoInit.oiPool.IsEmpty())
            {
                objectInfo = (WriteObjectInfo)serObjectInfoInit.oiPool.Pop();
                objectInfo.InternalInit();
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo from pool");
            }
            else
            {
                objectInfo = new WriteObjectInfo();
                objectInfo.objectInfoId = serObjectInfoInit.objectInfoIdCount++;                        
                //InternalST.Soap( "GetObjectInfo",objectInfo.objectInfoId," GetObjectInfo new not from pool");				
            }

            return objectInfo;
        }
        internal static WriteObjectInfo Serialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
        {
            WriteObjectInfo objectInfo = GetObjectInfo(serObjectInfoInit);

            objectInfo.InitSerialize(obj, surrogateSelector, context, serObjectInfoInit, converter, attributeInfo, objectWriter);
            return(objectInfo);
        }
示例#27
0
        // Read Constructor
        internal void Init(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, String assemblyName)
        {

            InternalST.Soap( this, objectInfoId," Constructor 3 ",objectType);     

            this.objectType = objectType;
            this.objectManager = objectManager;
            this.context = context;
            this.serObjectInfoInit = serObjectInfoInit;
            this.formatterConverter = converter;

            InitReadConstructor(objectType, surrogateSelector, context, assemblyName);
        }
示例#28
0
        internal static ReadObjectInfo Create(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, string assemblyName)
        {
            ReadObjectInfo objectInfo = GetObjectInfo(serObjectInfoInit);

            objectInfo.Init(objectType, surrogateSelector, context, objectManager, serObjectInfoInit, converter, assemblyName);
            return(objectInfo);
        }
示例#29
0
        // Read Constructor
        internal void Init(Type objectType, String[] memberNames, Type[] memberTypes, ISurrogateSelector surrogateSelector, StreamingContext context, ObjectManager objectManager, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, String assemblyName)
        {
            InternalST.Soap( this,objectInfoId, " Constructor 5 ",objectType);                     
            this.objectType = objectType;
            this.objectManager = objectManager;
            this.wireMemberNames = memberNames;
            this.wireMemberTypes = memberTypes;
            this.context = context;
            this.serObjectInfoInit = serObjectInfoInit;     
            this.formatterConverter = converter;
            if (memberNames != null)
                isNamed = true;
            if (memberTypes != null)
                isTyped = true;

            InitReadConstructor(objectType, surrogateSelector, context, assemblyName);                
        }
示例#30
0
        // Write constructor
        internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
        {
            InternalST.Soap(this, objectInfoId, " Constructor 1 ", obj);
            this.context                   = context;
            this.obj                       = obj;
            this.serObjectInfoInit         = serObjectInfoInit;
            this.parentMemberAttributeInfo = attributeInfo;
            this.surrogateSelector         = surrogateSelector;
            this.converter                 = converter;
            ISurrogateSelector surrogateSelectorTemp;

            if (RemotingServices.IsTransparentProxy(obj))
            {
                objectType = Converter.typeofMarshalByRefObject;
            }
            else
            {
                objectType = obj.GetType();
            }

            if (objectType.IsArray)
            {
                arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
                typeAttributeInfo   = GetTypeAttributeInfo();
                isArray             = true;
                InitNoMembers();
                return;
            }

            InternalST.Soap(this, objectInfoId, " Constructor 1 trace 2");

            typeAttributeInfo = GetTypeAttributeInfo();

            objectWriter.ObjectManager.RegisterObject(obj);
            if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null)
            {
                InternalST.Soap(this, objectInfoId, " Constructor 1 trace 3");
                si = new SerializationInfo(objectType, converter);
                if (!objectType.IsPrimitive)
                {
                    serializationSurrogate.GetObjectData(obj, si, context);
                }
                InitSiWrite(objectWriter);
            }
            else if (obj is ISerializable)
            {
                if (!objectType.IsSerializable)
                {
                    throw new SerializationException(String.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NonSerType"),
                                                                   objectType.FullName, objectType.Module.Assembly.FullName));
                }
                si = new SerializationInfo(objectType, converter);
                ((ISerializable)obj).GetObjectData(si, context);
                InternalST.Soap(this, objectInfoId, " Constructor 1 trace 4 ISerializable " + objectType);
                InitSiWrite(objectWriter);
            }
            else
            {
                InternalST.Soap(this, objectInfoId, " Constructor 1 trace 5");
                InitMemberInfo();
            }
        }
示例#31
0
        // Commences the process of serializing the entire graph.
        // initialize the graph walker.
        internal void Serialize(Object graph, Header[] inHeaders, SoapWriter serWriter)
        {
            InternalST.Soap( this, "Serialize Entry 2 ",graph,((headers == null)?" no headers ": "headers"));

            serializationPermission.Demand();

            if (graph == null)
                throw new ArgumentNullException("graph",SoapUtil.GetResourceString("ArgumentNull_Graph"));

            if (serWriter == null)
                throw new ArgumentNullException("serWriter",String.Format(SoapUtil.GetResourceString("ArgumentNull_WithParamName"), "serWriter"));

            serObjectInfoInit = new SerObjectInfoInit();        
            this.serWriter = serWriter;
            this.headers = inHeaders;

            if (graph is IMethodMessage)
            {
                bRemoting = true;
                MethodBase methodBase = ((IMethodMessage)graph).MethodBase;
                if (methodBase != null)
                    serWriter.WriteXsdVersion(ProcessTypeAttributes(methodBase.ReflectedType));
                else
                    serWriter.WriteXsdVersion(XsdVersion.V2001);
            }
            else
                serWriter.WriteXsdVersion(XsdVersion.V2001);

            m_idGenerator = new ObjectIDGenerator();
            m_objectQueue = new Queue();

            if (graph is ISoapMessage)
            {
                // Fake method call is to be written
                bRemoting = true;
                ISoapMessage ismc = (ISoapMessage)graph;
                graph = new InternalSoapMessage(ismc.MethodName, ismc.XmlNameSpace, ismc.ParamNames, ismc.ParamValues, ismc.ParamTypes);
                headers = ismc.Headers;
            }


            InternalST.Soap( this, "Serialize New SerializedTypeTable");
            m_serializedTypeTable = new Hashtable();

            serWriter.WriteBegin();

            long headerId = 0;
            Object obj;
            long objectId;
            bool isNew;

            topId = m_idGenerator.GetId(graph, out isNew);

            if (headers != null)
                headerId = m_idGenerator.GetId(headers, out isNew);
            else
                headerId = -1;

            WriteSerializedStreamHeader(topId, headerId);

            InternalST.Soap( this, "Serialize Schedule 0");

            // Write out SerializedStream header
            if (!((headers == null) || (headers.Length == 0)))
            {
                ProcessHeaders(headerId);
            }

            m_objectQueue.Enqueue(graph);

            while ((obj = GetNext(out objectId))!=null)
            {
                InternalST.Soap( this, "Serialize GetNext ",obj);
                WriteObjectInfo objectInfo = null;

                // GetNext will return either an object or a WriteObjectInfo. 
                // A WriteObjectInfo is returned if this object was member of another object
                if (obj is WriteObjectInfo)
                {
                    InternalST.Soap( this, "Serialize GetNext recognizes WriteObjectInfo");
                    objectInfo = (WriteObjectInfo)obj;
                }
                else
                {
                    objectInfo = WriteObjectInfo.Serialize(obj, m_surrogates, m_context, serObjectInfoInit, m_formatterConverter, null);
                    objectInfo.assemId = GetAssemblyId(objectInfo);
                }

                objectInfo.objectId = objectId;
                NameInfo typeNameInfo = TypeToNameInfo(objectInfo);
                typeNameInfo.NIisTopLevelObject = true;
                if (bRemoting && obj  == graph)
                    typeNameInfo.NIisRemoteRecord = true;
                Write(objectInfo, typeNameInfo, typeNameInfo);
                PutNameInfo(typeNameInfo);
                objectInfo.ObjectEnd();
            }

            serWriter.WriteSerializationHeaderEnd();
            serWriter.WriteEnd();

            m_idGenerator = new ObjectIDGenerator();
            InternalST.Soap( this, "*************Serialize New SerializedTypeTable 2");
            m_serializedTypeTable = new System.Collections.Hashtable();

            InternalST.Soap( this, "Serialize Exit ");
        }
示例#32
0
        internal static WriteObjectInfo Serialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
        {
            WriteObjectInfo soi = GetObjectInfo(serObjectInfoInit);

            soi.InitSerialize(objectType, surrogateSelector, context, serObjectInfoInit, converter, attributeInfo);
            return(soi);
        }