Serialize() private method

private Serialize ( object graph, System.Runtime.Serialization.Formatters.Binary.BinaryFormatterWriter serWriter, bool fCheck ) : void
graph object
serWriter System.Runtime.Serialization.Formatters.Binary.BinaryFormatterWriter
fCheck bool
return void
        public void Serialize(Stream serializationStream, object graph)
        {
            // don't refactor the 'throw' into a helper method; linker will have difficulty trimming
            if (!LocalAppContextSwitches.BinaryFormatterEnabled)
            {
                throw new NotSupportedException(SR.BinaryFormatter_SerializationDisallowed);
            }

            ArgumentNullException.ThrowIfNull(serializationStream);

            var formatterEnums = new InternalFE()
            {
                _typeFormat         = _typeFormat,
                _serializerTypeEnum = InternalSerializerTypeE.Binary,
                _assemblyFormat     = _assemblyFormat,
            };

            try
            {
                BinaryFormatterEventSource.Log.SerializationStart();
                var sow = new ObjectWriter(_surrogates, _context, formatterEnums, _binder);
                BinaryFormatterWriter binaryWriter = new BinaryFormatterWriter(serializationStream, sow, _typeFormat);
                sow.Serialize(graph, binaryWriter);
                _crossAppDomainArray = sow._crossAppDomainArray;
            }
            finally
            {
                BinaryFormatterEventSource.Log.SerializationStop();
            }
        }
Esempio n. 2
0
        internal void Serialize(Stream serializationStream, object graph, Header[] headers, bool fCheck)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream", Environment.GetResourceString("ArgumentNull_WithParamName", (object)serializationStream));
            }
            ObjectWriter objectWriter = new ObjectWriter(this.m_surrogates, this.m_context, new InternalFE()
            {
                FEtypeFormat = this.m_typeFormat, FEserializerTypeEnum = InternalSerializerTypeE.Binary, FEassemblyFormat = this.m_assemblyFormat
            }, this.m_binder);
            __BinaryWriter serWriter = new __BinaryWriter(serializationStream, objectWriter, this.m_typeFormat);

            objectWriter.Serialize(graph, headers, serWriter, fCheck);
            this.m_crossAppDomainArray = objectWriter.crossAppDomainArray;
        }
Esempio n. 3
0
        // Commences the process of serializing the entire graph.  All of the data (in the appropriate format
        // is emitted onto the stream).
        internal void Serialize(Stream serializationStream, Object graph, Header[] headers, bool fCheck)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException("serializationStream", String.Format(Environment.GetResourceString("ArgumentNull_WithParamName"), serializationStream));
            }
            SerTrace.Log(this, "Serialize Entry");

            InternalFE formatterEnums = new InternalFE();

            formatterEnums.FEtypeFormat         = m_typeFormat;
            formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Binary;
            formatterEnums.FEassemblyFormat     = m_assemblyFormat;
            ObjectWriter   sow          = new ObjectWriter(serializationStream, m_surrogates, m_context, formatterEnums);
            __BinaryWriter binaryWriter = new __BinaryWriter(serializationStream, sow, m_typeFormat);

            sow.Serialize(graph, headers, binaryWriter, fCheck);
            m_crossAppDomainArray = sow.crossAppDomainArray;
        }
Esempio n. 4
0
        internal void Serialize(Stream serializationStream, object graph, Header[] headers, bool check)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException(nameof(serializationStream));
            }

            var formatterEnums = new InternalFE()
            {
                _typeFormat         = _typeFormat,
                _serializerTypeEnum = InternalSerializerTypeE.Binary,
                _assemblyFormat     = _assemblyFormat,
            };

            var sow = new ObjectWriter(_surrogates, _context, formatterEnums, _binder);
            BinaryFormatterWriter binaryWriter = new BinaryFormatterWriter(serializationStream, sow, _typeFormat);

            sow.Serialize(graph, headers, binaryWriter, check);
            _crossAppDomainArray = sow._crossAppDomainArray;
        }
        // Commences the process of serializing the entire graph.  All of the data (in the appropriate format
        // is emitted onto the stream).
        internal void Serialize(Stream serializationStream, Object graph, Header[] headers, bool fCheck)
        {
            if (serializationStream==null)
            {
                throw new ArgumentNullException("serializationStream", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentNull_WithParamName"),serializationStream));             
            }
            SerTrace.Log(this, "Serialize Entry");

            InternalFE formatterEnums = new InternalFE();
            formatterEnums.FEtypeFormat = m_typeFormat;
            formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Binary;
            formatterEnums.FEassemblyFormat = m_assemblyFormat;    

            ObjectWriter sow = new ObjectWriter(m_surrogates, m_context, formatterEnums);
            __BinaryWriter binaryWriter = new __BinaryWriter(serializationStream, sow, m_typeFormat); 
            sow.Serialize(graph, headers, binaryWriter, fCheck);
            m_crossAppDomainArray = sow.crossAppDomainArray;
        }
Esempio n. 6
0
        internal void Serialize(Stream serializationStream, object graph, bool check)
        {
            if (serializationStream == null)
            {
                throw new ArgumentNullException(nameof(serializationStream));
            }

            var formatterEnums = new InternalFE()
            {
                _typeFormat = _typeFormat,
                _serializerTypeEnum = InternalSerializerTypeE.Binary,
                _assemblyFormat = _assemblyFormat,
            };

            var sow = new ObjectWriter(_surrogates, _context, formatterEnums, _binder);
            BinaryFormatterWriter binaryWriter = new BinaryFormatterWriter(serializationStream, sow, _typeFormat);
            sow.Serialize(graph, binaryWriter, check);
            _crossAppDomainArray = sow._crossAppDomainArray;
        }
 internal void Serialize(Stream serializationStream, object graph, Header[] headers, bool fCheck)
 {
     if (serializationStream == null)
     {
         throw new ArgumentNullException("serializationStream", Environment.GetResourceString("ArgumentNull_WithParamName", new object[] { serializationStream }));
     }
     InternalFE formatterEnums = new InternalFE {
         FEtypeFormat = this.m_typeFormat,
         FEserializerTypeEnum = InternalSerializerTypeE.Binary,
         FEassemblyFormat = this.m_assemblyFormat
     };
     ObjectWriter objectWriter = new ObjectWriter(this.m_surrogates, this.m_context, formatterEnums, this.m_binder);
     __BinaryWriter serWriter = new __BinaryWriter(serializationStream, objectWriter, this.m_typeFormat);
     objectWriter.Serialize(graph, headers, serWriter, fCheck);
     this.m_crossAppDomainArray = objectWriter.crossAppDomainArray;
 }