Beispiel #1
0
        // Commences the process of serializing the entire graph.  All of the data (in the appropriate format)
        // is emitted onto the stream.

        public void Serialize(Stream serializationStream, Object graph, Header[] headers)
        {
            InternalST.InfoSoap("Enter SoapFormatter.Serialize ");
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }

            InternalST.Soap(this, "Serialize Entry");
            InternalFE formatterEnums = new InternalFE();

            formatterEnums.FEtypeFormat         = m_typeFormat;
            formatterEnums.FEtopObject          = m_topObject;
            formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Soap;
            formatterEnums.FEassemblyFormat     = m_assemblyFormat;
            ObjectWriter sow = new ObjectWriter(serializationStream, m_surrogates, m_context, formatterEnums);

            sow.Serialize(graph, headers, new SoapWriter(serializationStream));
            InternalST.InfoSoap("Leave SoapFormatter.Serialize ");
        }
Beispiel #2
0
        // Deserialize the stream into an object graph.
        public Object Deserialize(Stream serializationStream, HeaderHandler handler)
        {
            InternalST.InfoSoap("Enter SoapFormatter.Deserialize ");
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }

            if (serializationStream.CanSeek && (serializationStream.Length == 0))
            {
                throw new SerializationException(SoapUtil.GetResourceString("Serialization_Stream"));
            }

            InternalST.Soap(this, "Deserialize Entry");
            InternalFE formatterEnums = new InternalFE();

            formatterEnums.FEtypeFormat         = m_typeFormat;
            formatterEnums.FEtopObject          = m_topObject;
            formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Soap;
            formatterEnums.FEassemblyFormat     = m_assemblyFormat;
            formatterEnums.FEsecurityLevel      = m_securityLevel;
            ObjectReader sor = new ObjectReader(serializationStream, m_surrogates, m_context, formatterEnums, m_binder);

            // If this is the first call, or a new stream is being used a new Soap parser is created.
            // If this is a continuing call, then the existing SoapParser is used.
            // One stream can contains multiple Soap XML documents. The XMLParser buffers the XML so
            // that the same XMLParser has to be used to continue a stream.
            if ((soapParser == null) || (serializationStream != currentStream))
            {
                soapParser    = new SoapParser(serializationStream);
                currentStream = serializationStream;
            }
            soapParser.Init(sor);
            Object obj = sor.Deserialize(handler, soapParser);

            InternalST.InfoSoap("Leave SoapFormatter.Deserialize ");
            return(obj);
        }