/// <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); } }
/** <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); } }); }
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); } } }