Table of Contents

Class ISerializerExtensions

Namespace
Ecng.Serialization
Assembly
Ecng.Serialization.dll

Provides extension methods for the ISerializer and ISerializer<T> interfaces to support serialization and deserialization operations with files, streams, and byte arrays.

public static class ISerializerExtensions
Inheritance
ISerializerExtensions
Inherited Members

Methods

Deserialize(ISerializer, byte[])

Deserializes the specified byte array into an object.

public static object Deserialize(this ISerializer serializer, byte[] data)

Parameters

serializer ISerializer

The serializer instance.

data byte[]

The byte array containing the serialized data.

Returns

object

The deserialized object.

Deserialize(ISerializer, Stream)

Deserializes the data from the given stream into an object.

public static object Deserialize(this ISerializer serializer, Stream stream)

Parameters

serializer ISerializer

The serializer instance.

stream Stream

The stream containing the serialized data.

Returns

object

The deserialized object.

Deserialize<T>(ISerializer<T>, byte[])

Deserializes the specified byte array into an object of type T.

public static T Deserialize<T>(this ISerializer<T> serializer, byte[] data)

Parameters

serializer ISerializer<T>

The serializer instance.

data byte[]

The byte array containing the serialized data.

Returns

T

An object of type T.

Type Parameters

T

The type of object to deserialize.

Deserialize<T>(ISerializer<T>, Stream)

Deserializes the data from the given stream into an object of type T.

public static T Deserialize<T>(this ISerializer<T> serializer, Stream stream)

Parameters

serializer ISerializer<T>

The serializer instance.

stream Stream

The stream containing the serialized data.

Returns

T

An object of type T.

Type Parameters

T

The type of object to deserialize.

Deserialize<T>(ISerializer<T>, string)

Deserializes the data from the specified file into an object of type T.

public static T Deserialize<T>(this ISerializer<T> serializer, string fileName)

Parameters

serializer ISerializer<T>

The serializer instance.

fileName string

The path of the file to read from.

Returns

T

An object of type T.

Type Parameters

T

The type of object to deserialize.

Serialize(ISerializer, object)

Serializes the specified object graph and returns the result as a byte array.

public static byte[] Serialize(this ISerializer serializer, object graph)

Parameters

serializer ISerializer

The serializer instance.

graph object

The object graph to serialize.

Returns

byte[]

A byte array containing the serialized data.

Serialize(ISerializer, object, Stream)

Serializes the specified object graph and writes the output to the provided stream.

public static void Serialize(this ISerializer serializer, object graph, Stream stream)

Parameters

serializer ISerializer

The serializer instance.

graph object

The object graph to serialize.

stream Stream

The stream to which to write the serialized data.

Serialize(ISerializer, object, string)

Serializes the specified object graph and writes the output to a file.

public static void Serialize(this ISerializer serializer, object graph, string fileName)

Parameters

serializer ISerializer

The serializer instance.

graph object

The object graph to serialize.

fileName string

The path of the file to write to.