コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public SerializableObjectHolder(BinaryReader reader)
        {
            Debug.Assert(reader != null);

            using (var streamAdapter = new BinaryStreamAdapter(reader.Stream))
            {
                _item = new BinaryFormatter().Deserialize(streamAdapter, null);
            }
        }
コード例 #2
0
        /** <inheritDoc /> */
        public void WriteBinary(IBinaryWriter writer)
        {
            Debug.Assert(writer != null);

            var writer0 = (BinaryWriter)writer.GetRawWriter();

            writer0.WithDetach(w =>
            {
                using (var streamAdapter = new BinaryStreamAdapter(w.Stream))
                {
                    new BinaryFormatter().Serialize(streamAdapter, Item);
                }
            });
        }
コード例 #3
0
        public void WriteBinary(IBinaryWriter writer)
        {
            var writer0 = (BinaryWriter) writer.GetRawWriter();

            if (writer0.IsBinarizable(_err))
            {
                writer0.WriteBoolean(true);
                writer0.WriteObject(_err);
            }
            else
            {
                writer0.WriteBoolean(false);

                using (var streamAdapter = new BinaryStreamAdapter(writer0.Stream))
                {
                    new BinaryFormatter().Serialize(streamAdapter, _err);
                }
            }
        }