Skip to content

Basic Usage

Michael Brown edited this page Dec 2, 2018 · 1 revision
using AnySerializer;

var originalObject = new SomeComplexTypeWithDeepStructure();
var bytes = Serializer.Serialize(originalObject);
var restoredObject = Serializer.Deserialize<SomeComplexTypeWithDeepStructure>(bytes);

Extension usage:

using AnySerializer;

var originalObject = new SomeComplexTypeWithDeepStructure();
var bytes = originalObject.Serialize();
var restoredObject = bytes.Deserialize<SomeComplexTypeWithDeepStructure>();

Embedding Type Descriptors

var originalObject = new SomeComplexTypeWithDeepStructure();
var bytes = Serializer.Serialize(originalObject, true); // true to embed type data
var restoredObject = Serializer.Deserialize<SomeComplexTypeWithDeepStructure>(bytes);

Validating binary data

var originalObject = new SomeComplexTypeWithDeepStructure();
var bytes = Serializer.Serialize(originalObject);
var isValid = Serializer.Validate(bytes);
Assert.IsTrue(isValid);