Class SerializationHelper
Namespace: CapyKit.Helpers
Assembly: CapyKit.dll
Syntax
public static class SerializationHelper
Methods
Deserialize<T>(byte[])
Deserializes an object to a given T type.
Declaration
public static T Deserialize<T>(byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | bytes | The byte array representing a |
Returns
| Type | Description |
|---|---|
| T | A |
Type Parameters
| Name | Description |
|---|---|
| T | Generic type parameter. |
Exceptions
| Type | Condition |
|---|---|
| FormatException | Thrown when the format of the byte array is incorrect. |
Deserialize<T>(Stream)
Deserializes an object to a given T type.
Declaration
public static T Deserialize<T>(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The steam. |
Returns
| Type | Description |
|---|---|
| T | A |
Type Parameters
| Name | Description |
|---|---|
| T | Generic type parameter. |
Exceptions
| Type | Condition |
|---|---|
| FormatException | Thrown when the format of an input is incorrect. |
Deserialize<T>(string)
Deserializes a JSON encoded string to the given T.
Declaration
public static T Deserialize<T>(string str)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str | The |
Returns
| Type | Description |
|---|---|
| T | A |
Type Parameters
| Name | Description |
|---|---|
| T | Generic type parameter. |
SerializeToBytes(object)
Serializes an object to a byte array.
Declaration
public static byte[] SerializeToBytes(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object. |
Returns
| Type | Description |
|---|---|
| byte[] | A |
SerializeToString(object)
Serializes an object to a JSON encoded string.
Declaration
public static string SerializeToString(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object. |
Returns
| Type | Description |
|---|---|
| string | A |