Example usage

Using FastBinaryFormatter is same as built-in .NET serialization formatters.

Album[] serializedObject = BuildAlbumArray(); // Example object graph.

var formatter = new FastBinaryFormatter();

// If required, define surragate selectors. var surrogateSelector = new SurrogateSelector(); surrogateSelector.AddSurrogate(typeof(Genre), new StreamingContext(), new GenreSerializationSurrogate()); formatter.SurrogateSelector.ChainSelector(surrogateSelector); using (var stream = new MemoryStream()) {
// Serialize. formatter.Serialize(stream, serializedObject); stream.Seek(0, SeekOrigin.Begin);
// Deserialize. var deserializedObject = (Album[])formatter.Deserialize(stream); }

Last edited Mar 18, 2014 at 1:27 PM by grammophone, version 5