Class DeserializerFactory
Represents a factory for deserializing JSON content into objects based on their registered type mappings.
Inherited Members
Namespace: Innovt.Core.Serialization
Assembly: Innovt.Core.dll
Syntax
public class DeserializerFactory
Properties
| Edit this page View SourceInstance
Gets the singleton instance of the DeserializerFactory.
Declaration
public static DeserializerFactory Instance { get; }
Property Value
Type | Description |
---|---|
DeserializerFactory |
Methods
| Edit this page View SourceAddMapping<T>(string)
Adds a type mapping to the factory, associating a key with a specific .NET type.
Declaration
public DeserializerFactory AddMapping<T>(string key = null)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key used to identify the type mapping. If not provided, the full name of the type will be used as the key. |
Returns
Type | Description |
---|---|
DeserializerFactory | The current DeserializerFactory instance for method chaining. |
Type Parameters
Name | Description |
---|---|
T | The .NET type to be associated with the key. |
Deserialize(string, string)
Deserializes JSON content into an object of the registered type associated with the specified key.
Declaration
public object Deserialize(string key, string content)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key associated with the registered type mapping. |
string | content | The JSON content to deserialize. |
Returns
Type | Description |
---|---|
object | The deserialized object of the registered type, or |
Deserialize<T>(string, string)
Deserializes JSON content into an object of the registered type associated with the specified key.
Declaration
public T Deserialize<T>(string key, string content)
Parameters
Type | Name | Description |
---|---|---|
string | key | The key associated with the registered type mapping. |
string | content | The JSON content to deserialize. |
Returns
Type | Description |
---|---|
T | The deserialized object of the specified type, or the default value for |
Type Parameters
Name | Description |
---|---|
T | The expected type of the deserialized object. |