Class SingleOrArrayConverter<T>
- Json.NET converter for OneOrMany<T>.
- Reads either a single T or T[].
Inherited Members
JsonConverter.CanRead
JsonConverter.CanWrite
Namespace: Glitch9.IO.Networking
Assembly: Glitch9.IO.dll
Syntax
public sealed class SingleOrArrayConverter<T> : JsonConverter<SingleOrArray<T>>
Type Parameters
| Name | Description |
|---|---|
| T |
Methods
| Edit this page View SourceReadJson(JsonReader, Type, SingleOrArray<T>, bool, JsonSerializer)
Reads the JSON representation of the object.
Declaration
public override SingleOrArray<T> ReadJson(JsonReader reader, Type objectType, SingleOrArray<T> existingValue, bool hasExistingValue, JsonSerializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonReader | reader | The Newtonsoft.Json.JsonReader to read from. |
| Type | objectType | Type of the object. |
| SingleOrArray<T> | existingValue | The existing value of object being read. If there is no existing value then |
| bool | hasExistingValue | The existing value has a value. |
| JsonSerializer | serializer | The calling serializer. |
Returns
| Type | Description |
|---|---|
| SingleOrArray<T> | The object value. |
Overrides
| Edit this page View SourceWriteJson(JsonWriter, SingleOrArray<T>, JsonSerializer)
Writes the JSON representation of the object.
Declaration
public override void WriteJson(JsonWriter writer, SingleOrArray<T> value, JsonSerializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonWriter | writer | The Newtonsoft.Json.JsonWriter to write to. |
| SingleOrArray<T> | value | The value. |
| JsonSerializer | serializer | The calling serializer. |