Class QueryParameterSerializer
class having static members for serializing query parameters to / from JSON
Inheritance
Inherited Members
Namespace: TimeCockpit.Data.JsonConverters
Assembly: TimeCockpit.Data.dll
Syntax
public class QueryParameterSerializer
Constructors
QueryParameterSerializer()
Declaration
public QueryParameterSerializer()
Methods
FromJSON(String, Model)
Reads query parameters from a json string.
Declaration
public static IEnumerable<QueryParameter> FromJSON(string json, Model model)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | json | the JSON string representation. |
| Model | model | The model. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<QueryParameter> | Returns the collection of query parameters. |
GetJSONObjectType(Type, Boolean)
returns a string describing the object type
Declaration
public static string GetJSONObjectType(Type type, bool serializeEntityObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | the .net type. |
| System.Boolean | serializeEntityObjects | true if entity objects should be serialized, false to only serialize guids. |
Returns
| Type | Description |
|---|---|
| System.String | Returns the string representing the object type. |
GetObjectValue(String, JsonReader, Model)
Returns the value of a query parameter, given the type and the JToken value
Declaration
public static object GetObjectValue(string type, JsonReader jr, Model model)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | type | string type of the value |
| Newtonsoft.Json.JsonReader | jr | the reader to read from. |
| Model | model | The model. |
Returns
| Type | Description |
|---|---|
| System.Object | returns the .net object |
ReadJSON(JsonReader, Model)
Converts a json string to a query parameter collection
Declaration
public static IEnumerable<QueryParameter> ReadJSON(JsonReader jsonReader, Model model)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | jsonReader | the json string to parse |
| Model | model | The model. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<QueryParameter> | returns an enumerable of QueryParameters |
ToJSON(IEnumerable<QueryParameter>, Model, Boolean)
Writes query parameters to a string.
Declaration
public static string ToJSON(IEnumerable<QueryParameter> queryParameters, Model model, bool serializeEntityObjects = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<QueryParameter> | queryParameters | query parameters to serialize. |
| Model | model | The model. |
| System.Boolean | serializeEntityObjects | True if EntityObjects should be serialized completely, false to only serialize the GUID. |
Returns
| Type | Description |
|---|---|
| System.String | Returns a string representation in JSON notation of the query parameters. |
WriteJSON(JsonWriter, Model, IEnumerable<QueryParameter>, Boolean)
converts a collection of query parameters to json
Declaration
public static void WriteJSON(JsonWriter jw, Model model, IEnumerable<QueryParameter> parameters, bool serializeEntityObjects = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonWriter | jw | json writer to write parameters to. |
| Model | model | The base model. |
| System.Collections.Generic.IEnumerable<QueryParameter> | parameters | the parameters to convert |
| System.Boolean | serializeEntityObjects | true if entity objects should be serialized, false to only serialize guids. |
WriteJSONObjectValue(Object, JsonWriter, Model, Boolean)
Gets a JSON compatible object value to store.
Declaration
public static void WriteJSONObjectValue(object value, JsonWriter jw, Model model, bool serializeEntityObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | the value to write. |
| Newtonsoft.Json.JsonWriter | jw | the writer to write the value to. |
| Model | model | The model. |
| System.Boolean | serializeEntityObjects | true if entity objects should be serialized, false to only serialize guids. |
WriteJsonParameter(JsonWriter, Model, QueryParameter, Boolean)
Writes the json parameter.
Declaration
public static void WriteJsonParameter(JsonWriter jw, Model model, QueryParameter parameter, bool serializeEntityObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonWriter | jw | The json writer. |
| Model | model | The base model. |
| QueryParameter | parameter | the parameter to write. |
| System.Boolean | serializeEntityObjects | true if entity objects should be serialized, false to only serialize guids. |