Table of Contents

Class DynamicJsonConverter

Namespace
Cuemon.Extensions.Newtonsoft.Json
Assembly
Cuemon.Extensions.Newtonsoft.Json.dll

Provides a factory based way to create and wrap an Newtonsoft.Json.JsonConverter implementation.

public static class DynamicJsonConverter
Inheritance
Object
DynamicJsonConverter

Methods

Create(JsonConverter)

Creates a dynamic instance of converter.

public static JsonConverter Create(JsonConverter converter)

Parameters

converter JsonConverter

The Newtonsoft.Json.JsonConverter to wrap.

Returns

JsonConverter

An Newtonsoft.Json.JsonConverter implementation of System.Type.

Create(Func<Type, Boolean>, Action<JsonWriter, Object, JsonSerializer>, Func<JsonReader, Type, Object, JsonSerializer, Object>)

Creates a dynamic instance of an Newtonsoft.Json.JsonConverter implementation wrapping Newtonsoft.Json.JsonConverter.CanConvert(System.Type) through predicate, Newtonsoft.Json.JsonConverter.WriteJson(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.JsonSerializer) through writer and Newtonsoft.Json.JsonConverter.ReadJson(Newtonsoft.Json.JsonReader, System.Type, System.Object, Newtonsoft.Json.JsonSerializer) through reader.

public static JsonConverter Create(Func<Type, bool> predicate, Action<JsonWriter, object, JsonSerializer> writer = null, Func<JsonReader, Type, object, JsonSerializer, object> reader = null)

Parameters

predicate Func<Type, Boolean>

The function delegate that validates if given System.Type can be converted to and from JSON.

writer Action<JsonWriter, Object, JsonSerializer>

The delegate that converts a given System.Type to its JSON representation.

reader Func<JsonReader, Type, Object, JsonSerializer, Object>

The function delegate that generates System.Type from its JSON representation.

Returns

JsonConverter

An Newtonsoft.Json.JsonConverter implementation of System.Type.

Create(Type, Action<JsonWriter, Object, JsonSerializer>, Func<JsonReader, Type, Object, JsonSerializer, Object>)

Creates a dynamic instance of an Newtonsoft.Json.JsonConverter implementation wrapping Newtonsoft.Json.JsonConverter.WriteJson(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.JsonSerializer) through writer and Newtonsoft.Json.JsonConverter.ReadJson(Newtonsoft.Json.JsonReader, System.Type, System.Object, Newtonsoft.Json.JsonSerializer) through reader.

public static JsonConverter Create(Type objectType, Action<JsonWriter, object, JsonSerializer> writer = null, Func<JsonReader, Type, object, JsonSerializer, object> reader = null)

Parameters

objectType Type

The type of the object to convert.

writer Action<JsonWriter, Object, JsonSerializer>

The delegate that converts objectType to its JSON representation.

reader Func<JsonReader, Type, Object, JsonSerializer, Object>

The function delegate that generates objectType from its JSON representation.

Returns

JsonConverter

An Newtonsoft.Json.JsonConverter implementation of objectType.

Create<T>(Action<JsonWriter, T, JsonSerializer>, Func<JsonReader, Type, T, JsonSerializer, T>)

Creates a dynamic instance of an Newtonsoft.Json.JsonConverter implementation wrapping Newtonsoft.Json.JsonConverter.WriteJson(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.JsonSerializer) through writer and Newtonsoft.Json.JsonConverter.ReadJson(Newtonsoft.Json.JsonReader, System.Type, System.Object, Newtonsoft.Json.JsonSerializer) through reader.

public static JsonConverter Create<T>(Action<JsonWriter, T, JsonSerializer> writer = null, Func<JsonReader, Type, T, JsonSerializer, T> reader = null)

Parameters

writer Action<JsonWriter, T, JsonSerializer>

The delegate that converts T to its JSON representation.

reader Func<JsonReader, Type, T, JsonSerializer, T>

The function delegate that generates T from its JSON representation.

Returns

JsonConverter

An Newtonsoft.Json.JsonConverter implementation of T.

Type Parameters

T

The type to implement an Newtonsoft.Json.JsonConverter.

Create<T>(Func<Type, Boolean>, Action<JsonWriter, T, JsonSerializer>, Func<JsonReader, Type, T, JsonSerializer, T>)

Creates a dynamic instance of an Newtonsoft.Json.JsonConverter implementation wrapping Newtonsoft.Json.JsonConverter.WriteJson(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.JsonSerializer) through writer and Newtonsoft.Json.JsonConverter.ReadJson(Newtonsoft.Json.JsonReader, System.Type, System.Object, Newtonsoft.Json.JsonSerializer) through reader.

public static JsonConverter Create<T>(Func<Type, bool> predicate, Action<JsonWriter, T, JsonSerializer> writer = null, Func<JsonReader, Type, T, JsonSerializer, T> reader = null)

Parameters

predicate Func<Type, Boolean>

The function delegate that validates if given System.Type can be converted to and from JSON.

writer Action<JsonWriter, T, JsonSerializer>

The delegate that, when predicate returns true, converts T to its JSON representation.

reader Func<JsonReader, Type, T, JsonSerializer, T>

The function delegate that, when predicate returns true, generates T from its JSON representation.

Returns

JsonConverter

An Newtonsoft.Json.JsonConverter implementation of T.

Type Parameters

T

The type to implement an Newtonsoft.Json.JsonConverter.