Exemple #1
0
        public void Serialize(Stream serializationStream, object graph, Header[] headers)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }
            if (!serializationStream.CanWrite)
            {
                throw new SerializationException("Can't write in the serialization stream");
            }
            if (graph == null)
            {
                throw new ArgumentNullException("graph");
            }
            SoapWriter  soapWriter = new SoapWriter(serializationStream, _selector, _context, _topObject);
            CultureInfo savedCi    = CultureInfo.CurrentCulture;

            try {
                Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
                soapWriter.Serialize(graph, headers, _typeFormat, _assemblyFormat);
            }
            finally {
                Thread.CurrentThread.CurrentCulture = savedCi;
            }
        }
Exemple #2
0
 public string GetInternalSoapValue(SoapWriter writer, object value)
 {
     if (CanBeValue(value.GetType()))
     {
         return(GetXsdValue(value));
     }
     else if (value is MethodSignature)
     {
         return(((MethodSignature)value).GetXmlValue(writer));
     }
     else
     {
         return(value.ToString());
     }
 }
Exemple #3
0
        public string GetXmlValue(SoapWriter writer)
        {
            StringBuilder sb = new StringBuilder();

            foreach (Type t in types)
            {
                Element elem = writer.Mapper.GetXmlElement(t);
                if (sb.Length > 0)
                {
                    sb.Append(' ');
                }
                string prefix = writer.GetNamespacePrefix(elem);
                sb.Append(prefix).Append(':').Append(elem.LocalName);
            }
            return(sb.ToString());
        }
Exemple #4
0
        public void Serialize(Stream serializationStream, object graph, Header[] headers)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }
            if (!serializationStream.CanWrite)
            {
                throw new SerializationException("Can't write in the serialization stream");
            }
            if (graph == null)
            {
                throw new ArgumentNullException("graph");
            }
            SoapWriter soapWriter = new SoapWriter(serializationStream, _selector, _context, _topObject);

            soapWriter.Serialize(graph, headers, _typeFormat, _assemblyFormat);
        }
Exemple #5
0
		public string GetXmlValue (SoapWriter writer)
		{
			StringBuilder sb = new StringBuilder ();
			foreach (Type t in types) {
				Element elem = writer.Mapper.GetXmlElement (t);
				if (sb.Length > 0) sb.Append (' ');
				string prefix = writer.GetNamespacePrefix (elem);
				sb.Append (prefix).Append (':').Append (elem.LocalName);
			}
			return sb.ToString ();
		}
Exemple #6
0
		public string GetInternalSoapValue (SoapWriter writer, object value)
		{
			if (CanBeValue (value.GetType()))
				return GetXsdValue (value);
			else if (value is MethodSignature)
				return ((MethodSignature)value).GetXmlValue (writer);
			else
				return value.ToString ();
		}
Exemple #7
0
		public void Serialize(Stream serializationStream, object graph, Header[] headers) {
			if(serializationStream == null)
				throw new ArgumentNullException("serializationStream");
			if(!serializationStream.CanWrite)
				throw new SerializationException("Can't write in the serialization stream");
			if(graph == null)
				throw new ArgumentNullException("graph");
			SoapWriter soapWriter = new SoapWriter(serializationStream, _selector, _context, _topObject);
			CultureInfo savedCi = CultureInfo.CurrentCulture;
			try {
				Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
				soapWriter.Serialize (graph, headers, _typeFormat, _assemblyFormat);
			}
			finally {
				Thread.CurrentThread.CurrentCulture = savedCi;
			}
			
		}
Exemple #8
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 ");
        }
 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();
 }
Exemple #10
0
		public void Serialize(Stream serializationStream, object graph, Header[] headers) {
			if(serializationStream == null)
				throw new ArgumentNullException("serializationStream");
			if(!serializationStream.CanWrite)
				throw new SerializationException("Can't write in the serialization stream");
			if(graph == null)
				throw new ArgumentNullException("graph");
			SoapWriter soapWriter = new SoapWriter(serializationStream, _selector, _context, _topObject);
			soapWriter.Serialize (graph, headers, _typeFormat, _assemblyFormat);
		}