C# Class EdjCase.JsonRpc.Core.JsonConverters.RpcIdJsonConverter

Converter to convert and enforce the id to be a string, number or null
Inheritance: Newtonsoft.Json.JsonConverter
ファイルを表示 Open project: edjCase/JsonRpc

Public Methods

Method Description
CanConvert ( Type objectType ) : bool

Determines if the type can be convertered with this converter

ReadJson ( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer ) : object

Read the json format and return the correct object type/value for it

WriteJson ( JsonWriter writer, object value, JsonSerializer serializer ) : void

Writes the value of the id to json format

Private Methods

Method Description
IsNumericType ( Type type ) : bool

Determines if the type is a number

ValidateValue ( object value ) : object

Validates that the value is a string, number or null and converts emtpy strings to null

Method Details

CanConvert() public method

Determines if the type can be convertered with this converter
public CanConvert ( Type objectType ) : bool
objectType System.Type Type of the object
return bool

ReadJson() public method

Read the json format and return the correct object type/value for it
public ReadJson ( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer ) : object
reader Newtonsoft.Json.JsonReader Json reader
objectType System.Type Type of property being set
existingValue object The current value of the property being set
serializer Newtonsoft.Json.JsonSerializer Json serializer
return object

WriteJson() public method

Writes the value of the id to json format
public WriteJson ( JsonWriter writer, object value, JsonSerializer serializer ) : void
writer Newtonsoft.Json.JsonWriter Json writer
value object Value to be converted to json format
serializer Newtonsoft.Json.JsonSerializer Json serializer
return void