Class Serializer
Implements
Inherited Members
Namespace: LemonEdge.Utils
Assembly: LemonEdge.Utils.dll
Syntax
public class Serializer : ISerializer
Constructors
Serializer()
Declaration
public Serializer()
Properties
Instance
Declaration
public static Serializer Instance { get; }
Property Value
Type | Description |
---|---|
Serializer |
Methods
BytesToString(byte[])
Converts bytes to string content
Declaration
public string BytesToString(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
byte[] | bytes | The byte array |
Returns
Type | Description |
---|---|
string | String content |
Deserialize(Type, byte[]?, IEnumerable<Type>?)
Deserializes from the specified data
into the specified type
Declaration
public object? Deserialize(Type type, byte[]? data, IEnumerable<Type>? knownTypes = null)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type the |
byte[] | data | The serialized stream |
IEnumerable<Type> | knownTypes | Additional known types involved in the original serialization |
Returns
Type | Description |
---|---|
object | A new instance of |
Deserialize(Type, string?, IEnumerable<Type>?)
Deserializes from the specified string
into the specified type
Declaration
public object? Deserialize(Type type, string? @string, IEnumerable<Type>? knownTypes = null)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type the |
string | string | The serialized stream |
IEnumerable<Type> | knownTypes | Additional known types involved in the original serialization |
Returns
Type | Description |
---|---|
object | A new instance of |
Deserialize<T>(byte[]?, IEnumerable<Type>?)
Deserializes from the specified data
into the specified type T
Declaration
public T Deserialize<T>(byte[]? data, IEnumerable<Type>? knownTypes = null)
Parameters
Type | Name | Description |
---|---|---|
byte[] | data | The serialized stream |
IEnumerable<Type> | knownTypes | Additional known types involved in the original serialization |
Returns
Type | Description |
---|---|
T | A new instance of T from the serialized |
Type Parameters
Name | Description |
---|---|
T | The type the |
Deserialize<T>(string?, IEnumerable<Type>?)
Deserializes from the specified stream
into the specified type T
Declaration
public T Deserialize<T>(string? stream, IEnumerable<Type>? knownTypes = null)
Parameters
Type | Name | Description |
---|---|---|
string | stream | The serialized stream |
IEnumerable<Type> | knownTypes | Additional known types involved in the original serialization |
Returns
Type | Description |
---|---|
T | A new instance of T from the serialized |
Type Parameters
Name | Description |
---|---|
T | The type the |
Serialize(object?, IEnumerable<Type>?)
Serializes the specified obj
into a string stream
Declaration
public string Serialize(object? obj, IEnumerable<Type>? knownTypes = null)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be serialized |
IEnumerable<Type> | knownTypes | Any known types referenced by the |
Returns
Type | Description |
---|---|
string | A serialized string of the |
SerializeToBytes(object?, IEnumerable<Type>?)
Serializes the specified obj
into a byte array stream
Declaration
public byte[] SerializeToBytes(object? obj, IEnumerable<Type>? knownTypes = null)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to be serialized |
IEnumerable<Type> | knownTypes | Any known types referenced by the |
Returns
Type | Description |
---|---|
byte[] | A serialized byte array of the |
StringToBytes(string)
Converts a string to a byte array
Declaration
public byte[] StringToBytes(string @string)
Parameters
Type | Name | Description |
---|---|---|
string | string | The string |
Returns
Type | Description |
---|---|
byte[] | A byte array |