Class QueryParameterSerializer
- Namespace
- TimeCockpit.Data.JsonConverters
- Assembly
- TimeCockpit.Data.dll
class having static members for serializing query parameters to / from JSON
public class QueryParameterSerializer
- Inheritance
-
ObjectQueryParameterSerializer
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
Constructors
QueryParameterSerializer()
public QueryParameterSerializer()
Methods
FromJSON(String, Model)
Reads query parameters from a json string.
public static IEnumerable<QueryParameter> FromJSON(string json, Model model)
Parameters
jsonStringthe JSON string representation.
modelModelThe model.
Returns
- IEnumerable<QueryParameter>
Returns the collection of query parameters.
GetJSONObjectType(Type, Boolean)
returns a string describing the object type
public static string GetJSONObjectType(Type type, bool serializeEntityObjects)
Parameters
typeTypethe .net type.
serializeEntityObjectsBooleantrue if entity objects should be serialized, false to only serialize guids.
Returns
- 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
public static object GetObjectValue(string type, JsonReader jr, Model model)
Parameters
typeStringstring type of the value
jrJsonReaderthe reader to read from.
modelModelThe model.
Returns
- Object
returns the .net object
ReadJSON(JsonReader, Model)
Converts a json string to a query parameter collection
public static IEnumerable<QueryParameter> ReadJSON(JsonReader jsonReader, Model model)
Parameters
jsonReaderJsonReaderthe json string to parse
modelModelThe model.
Returns
- IEnumerable<QueryParameter>
returns an enumerable of QueryParameters
ToJSON(IEnumerable<QueryParameter>, Model, Boolean)
Writes query parameters to a string.
public static string ToJSON(IEnumerable<QueryParameter> queryParameters, Model model, bool serializeEntityObjects = false)
Parameters
queryParametersIEnumerable<QueryParameter>query parameters to serialize.
modelModelThe model.
serializeEntityObjectsBooleanTrue if EntityObjects should be serialized completely, false to only serialize the GUID.
Returns
- 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
public static void WriteJSON(JsonWriter jw, Model model, IEnumerable<QueryParameter> parameters, bool serializeEntityObjects = false)
Parameters
jwJsonWriterjson writer to write parameters to.
modelModelThe base model.
parametersIEnumerable<QueryParameter>the parameters to convert
serializeEntityObjectsBooleantrue if entity objects should be serialized, false to only serialize guids.
WriteJSONObjectValue(Object, JsonWriter, Model, Boolean)
Gets a JSON compatible object value to store.
public static void WriteJSONObjectValue(object value, JsonWriter jw, Model model, bool serializeEntityObjects)
Parameters
valueObjectthe value to write.
jwJsonWriterthe writer to write the value to.
modelModelThe model.
serializeEntityObjectsBooleantrue if entity objects should be serialized, false to only serialize guids.
WriteJsonParameter(JsonWriter, Model, QueryParameter, Boolean)
Writes the json parameter.
public static void WriteJsonParameter(JsonWriter jw, Model model, QueryParameter parameter, bool serializeEntityObjects)
Parameters
jwJsonWriterThe json writer.
modelModelThe base model.
parameterQueryParameterthe parameter to write.
serializeEntityObjectsBooleantrue if entity objects should be serialized, false to only serialize guids.