Exemplo n.º 1
0
            //public object Deserialize(byte[] bytes)
            //{
            //    if(bytes == null || bytes.Length == 0) return new SessionStateItemCollection();
            //    using(var ms = new MemoryStream(bytes))
            //    using(var reader = new BinaryReader(ms, GA.UTF8))
            //    {
            //        return SessionStateItemCollection.Deserialize(reader);
            //    }
            //}

            //public byte[] Serialize(object value)
            //{
            //    if(value == null) return new byte[0];
            //    var item = value as SessionStateItemCollection;
            //    if(item.Count == 0) return new byte[0];
            //    using(var ms = new MemoryStream())
            //    using(var writer = new BinaryWriter(ms, GA.UTF8))
            //    {
            //        item.Serialize(writer);
            //        return ms.ToArray();
            //    }
            //}
            public object Deserialize(ObjectReader reader)
            {
                SessionStateItemCollection items = new SessionStateItemCollection();
                var count = reader.ReadInt32();

                for (int i = 0; i < count; i++)
                {
                    var name  = (string)reader.Deserialize();
                    var value = reader.Deserialize();
                    items[name] = value;
                }
                return(items);
            }
Exemplo n.º 2
0
        [System.Security.SecurityCritical]  // auto-generated
        internal Object Deserialize(Stream serializationStream, HeaderHandler handler, bool fCheck, bool isCrossAppDomain, IMethodCallMessage methodCallMessage)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream", ModifiedVulnerableBinaryFormatters.binary.Environment.GetResourceString("ArgumentNull_WithParamName", serializationStream));
            }
            Contract.EndContractBlock();

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

            SerTrace.Log(this, "Deserialize Entry");
            InternalFE formatterEnums = new InternalFE();

            formatterEnums.FEtypeFormat         = m_typeFormat;
            formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Binary;
            formatterEnums.FEassemblyFormat     = m_assemblyFormat;
            formatterEnums.FEsecurityLevel      = m_securityLevel;

            ObjectReader sor = new ObjectReader(serializationStream, m_surrogates, m_context, formatterEnums, m_binder);

            sor.crossAppDomainArray = m_crossAppDomainArray;
            return(sor.Deserialize(handler, new __BinaryParser(serializationStream, sor), fCheck, isCrossAppDomain, methodCallMessage));
        }
Exemplo n.º 3
0
        // [System.Security.SecurityCritical]  // auto-generated
        internal Object Deserialize(Stream serializationStream, HeaderHandler handler, bool fCheck)
        {
#if FEATURE_REMOTING
            return(Deserialize(serializationStream, handler, fCheck, null));
#else
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream", Ssz.Runtime.Serialization.Environment.GetResourceString("ArgumentNull_WithParamName", serializationStream));
            }
            Contract.EndContractBlock();

            if (serializationStream.CanSeek && (serializationStream.Length == 0))
            {
                throw new SerializationException(Ssz.Runtime.Serialization.Environment.GetResourceString("Serialization_Stream"));
            }

            SerTrace.Log(this, "Deserialize Entry");
            InternalFE formatterEnums = new InternalFE();
            formatterEnums.FEtypeFormat         = m_typeFormat;
            formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Binary;
            formatterEnums.FEassemblyFormat     = m_assemblyFormat;
            formatterEnums.FEsecurityLevel      = m_securityLevel;

            ObjectReader sor = new ObjectReader(serializationStream, m_surrogates, m_context, formatterEnums, m_binder);
            sor.crossAppDomainArray = m_crossAppDomainArray;
            return(sor.Deserialize(handler, new __BinaryParser(serializationStream, sor), fCheck));
#endif
        }
Exemplo n.º 4
0
        public object Deserialize(Stream serializationStream, HeaderHandler handler)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }
            if (serializationStream.CanSeek && (serializationStream.Length == 0L))
            {
                throw new SerializationException(SoapUtil.GetResourceString("Serialization_Stream"));
            }
            InternalFE formatterEnums = new InternalFE {
                FEtypeFormat         = this.m_typeFormat,
                FEtopObject          = this.m_topObject,
                FEserializerTypeEnum = InternalSerializerTypeE.Soap,
                FEassemblyFormat     = this.m_assemblyFormat,
                FEsecurityLevel      = this.m_securityLevel
            };
            ObjectReader objectReader = new ObjectReader(serializationStream, this.m_surrogates, this.m_context, formatterEnums, this.m_binder);

            if ((this.soapParser == null) || (serializationStream != this.currentStream))
            {
                this.soapParser    = new SoapParser(serializationStream);
                this.currentStream = serializationStream;
            }
            this.soapParser.Init(objectReader);
            return(objectReader.Deserialize(handler, this.soapParser));
        }
Exemplo n.º 5
0
                public object Deserialize(ObjectReader reader)
                {
                    var value = (int)reader.Deserialize();

                    return(new Property()
                    {
                        Value = value + 1
                    });
                }
Exemplo n.º 6
0
                public object Deserialize(ObjectReader reader)
                {
                    var value = (int)reader.Deserialize();

                    return(new CustomFormatter1()
                    {
                        Value = value + 1
                    });
                }
Exemplo n.º 7
0
        /// <summary>
        /// Deserializes the data on the provided stream and reconstitutes the graph of objects.
        /// </summary>
        /// <param name="serializationStream">The stream containing the data to deserialize.</param>
        /// <returns>The top object of the deserialized graph.</returns>
        public object Deserialize(Stream /*!*/ serializationStream)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream");
            }

            serializationPermission.Demand();

            ScriptContext context       = ScriptContext.CurrentContext;
            ObjectReader  object_reader = new ObjectReader(context, new StreamReader(serializationStream, encoding), decodeOptions);

            return(object_reader.Deserialize());
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
		/// <summary>
		/// Deserializes the data on the provided stream and reconstitutes the graph of objects.
		/// </summary>
		/// <param name="serializationStream">The stream containing the data to deserialize.</param>
		/// <returns>The top object of the deserialized graph.</returns>
		public object Deserialize(Stream serializationStream)
		{
			if (serializationStream == null)
			{
				throw new ArgumentNullException("serializationStream");
			}
			serializationPermission.Demand();

			ScriptContext context = ScriptContext.CurrentContext;
			ObjectReader object_reader = new ObjectReader(context, serializationStream, encoding, caller);
            return object_reader.Deserialize();
		}