Class EntityObjectJsonConverter
Custom serializer for EntityObjects into Json.
Inheritance
Inherited Members
Namespace: TimeCockpit.Data.JsonConverters
Assembly: TimeCockpit.Data.dll
Syntax
public class EntityObjectJsonConverter
Constructors
EntityObjectJsonConverter()
Declaration
public EntityObjectJsonConverter()
Methods
CreateEntityObjectFromPrototype(JsonReader, Model, Environment, Boolean)
Create an entity object from a json prototype (igoring missing members etc.).
Declaration
public static EntityObject CreateEntityObjectFromPrototype(JsonReader reader, Model model, Environment environment, bool evaluateMissingDefaultValues)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | Json reader. |
| Model | model | Data model. |
| Environment | environment | The environment of the current datacontext used to validate permissions. |
| System.Boolean | evaluateMissingDefaultValues |
Returns
| Type | Description |
|---|---|
| EntityObject | New entity object from prototype. |
ReadEntityObject(JsonReader, Dictionary<String, ModelEntityBase>, Model, Environment, Dictionary<Guid, EntityObject>)
Reads the entity object.
Declaration
public static EntityObject ReadEntityObject(JsonReader reader, Dictionary<string, ModelEntityBase> anonymousTypes, Model model, Environment environment, Dictionary<Guid, EntityObject> alreadyLoaded)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | The reader. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | anonymousTypes | The anonymous types. |
| Model | model | The model. |
| Environment | environment | The environment. |
| System.Collections.Generic.Dictionary<System.Guid, EntityObject> | alreadyLoaded | Previously loaded entity objects (for relations) |
Returns
| Type | Description |
|---|---|
| EntityObject | Returns the read EntityObject instance. |
ReadEntityObject(JObject, Dictionary<String, ModelEntityBase>, Model, Environment, Dictionary<Guid, EntityObject>)
Reads an instance of EntityObject that is serialized in Json
Declaration
public static EntityObject ReadEntityObject(JObject obj, Dictionary<string, ModelEntityBase> anonymousTypes, Model model, Environment environment, Dictionary<Guid, EntityObject> alreadyLoaded)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.Linq.JObject | obj | obj to read from. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | anonymousTypes | anonymous types for deserialization additionally to model. |
| Model | model | The current data context model |
| Environment | environment | Current DataContext environment. |
| System.Collections.Generic.Dictionary<System.Guid, EntityObject> | alreadyLoaded | already loaded entity objects. |
Returns
| Type | Description |
|---|---|
| EntityObject | an instance of EntityObject |
ReadEntityObjectArray(JsonReader, Dictionary<String, ModelEntityBase>, Model, Environment)
Reads the EntityObjects out of an array of EntityObjects.
Declaration
public static List<EntityObject> ReadEntityObjectArray(JsonReader reader, Dictionary<string, ModelEntityBase> anonymousTypes, Model model, Environment environment)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | The json reader. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | anonymousTypes | Anonymous types in a case of a Select New With query. |
| Model | model | An instance of Model that holds metadata. |
| Environment | environment | The current environment. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<EntityObject> | A list of EntityObjects. |
ReadHomogenousEntityObject(JsonReader, EntityObjectJsonConverter.JsonSchemaModelEntity, Dictionary<Guid, EntityObject>, Environment, Model, Dictionary<String, ModelEntityBase>, out Boolean)
Reads an homogenous entity object from a reader.
Declaration
public static EntityObject ReadHomogenousEntityObject(JsonReader reader, EntityObjectJsonConverter.JsonSchemaModelEntity schema, Dictionary<Guid, EntityObject> entityObjectCache, Environment environment, Model model, Dictionary<string, ModelEntityBase> additionalTypes, out bool done)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | json reader to read an entity object from. |
| EntityObjectJsonConverter.JsonSchemaModelEntity | schema | schema of the model entity. |
| System.Collections.Generic.Dictionary<System.Guid, EntityObject> | entityObjectCache | a dictionary containing the already parsed entity objects. |
| Environment | environment | environment for refreshing permissions. |
| Model | model | the model used for deserialization. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | additionalTypes | additional Types used for deserialization. |
| System.Boolean | done | out param indicating whether we're done reading |
Returns
| Type | Description |
|---|---|
| EntityObject | returns an entityobject serialized from the reader. |
ReadHomogenousEntityObjectArray(JsonReader, Model, Dictionary<String, ModelEntityBase>, Environment)
Reads the homogenous entity object array.
Declaration
public static IEnumerable<EntityObject> ReadHomogenousEntityObjectArray(JsonReader reader, Model modelBase, Dictionary<string, ModelEntityBase> additionalTypes, Environment environment)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | The json reader to read an entity object collection from. |
| Model | modelBase | model holding possible types. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | additionalTypes | additional types used for deserialization. |
| Environment | environment | the environment for refreshing permissions. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<EntityObject> | Returns an enumerable iterating over the entity objects read from the reader. |
ReadHomogenousEntityObjectArrayValues(JsonReader, EntityObjectJsonConverter.JsonSchemaModelEntity, Dictionary<Guid, EntityObject>, Environment, Model, Dictionary<String, ModelEntityBase>)
Reads the homogenous entity object array values.
Declaration
public static IEnumerable<EntityObject> ReadHomogenousEntityObjectArrayValues(JsonReader reader, EntityObjectJsonConverter.JsonSchemaModelEntity schema, Dictionary<Guid, EntityObject> objectCache, Environment environment, Model model, Dictionary<string, ModelEntityBase> additionalTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | The reader. |
| EntityObjectJsonConverter.JsonSchemaModelEntity | schema | the schema used for deserialization. |
| System.Collections.Generic.Dictionary<System.Guid, EntityObject> | objectCache | a cache holding references to already deserialized objects. used for relations. |
| Environment | environment | environment for refreshing permissions. |
| Model | model | the model used for deserialization. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | additionalTypes | additional types used for deserialization. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<EntityObject> | the deserialized entity objects. |
ReadSchema(JsonReader, Model, Dictionary<String, ModelEntityBase>, Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>)
Reads the schema from a json reader.
Declaration
public static EntityObjectJsonConverter.JsonSchemaModelEntity ReadSchema(JsonReader reader, Model baseModel, Dictionary<string, ModelEntityBase> additionalTypes, Dictionary<string, EntityObjectJsonConverter.JsonSchemaModelEntity> deserializedSchemas)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | the reader to read from. |
| Model | baseModel | base model for data types. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | additionalTypes | types additional to the model. |
| System.Collections.Generic.Dictionary<System.String, EntityObjectJsonConverter.JsonSchemaModelEntity> | deserializedSchemas | already deserialized schemas. |
Returns
| Type | Description |
|---|---|
| EntityObjectJsonConverter.JsonSchemaModelEntity | returns a json schema model entity. |
ReadSchemaMembers(JsonReader, ModelEntityBase, Model, Dictionary<String, ModelEntityBase>, Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>, List<EntityObjectJsonConverter.JsonSchemaProperty>, List<EntityObjectJsonConverter.JsonSchemaRelation>)
Reads the members of theschema
Declaration
public static void ReadSchemaMembers(JsonReader reader, ModelEntityBase modelEntity, Model baseModel, Dictionary<string, ModelEntityBase> additionalTypes, Dictionary<string, EntityObjectJsonConverter.JsonSchemaModelEntity> deserializedSchemas, List<EntityObjectJsonConverter.JsonSchemaProperty> properties, List<EntityObjectJsonConverter.JsonSchemaRelation> relations)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | The reader to read from. |
| ModelEntityBase | modelEntity | The model entity. |
| Model | baseModel | base model containing basic types. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | additionalTypes | additional data types for deserialization. |
| System.Collections.Generic.Dictionary<System.String, EntityObjectJsonConverter.JsonSchemaModelEntity> | deserializedSchemas | already deserialized schemas. |
| System.Collections.Generic.List<EntityObjectJsonConverter.JsonSchemaProperty> | properties | The properties collection to insert properties into. |
| System.Collections.Generic.List<EntityObjectJsonConverter.JsonSchemaRelation> | relations | The relations collection to insert relations into. |
ReadSchemaRelation(JsonReader, Model, Dictionary<String, ModelEntityBase>, ModelEntityBase, Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>)
Reads the schema of a relation.
Declaration
public static EntityObjectJsonConverter.JsonSchemaRelation ReadSchemaRelation(JsonReader reader, Model baseModel, Dictionary<string, ModelEntityBase> additionalTypes, ModelEntityBase ownerModelEntity, Dictionary<string, EntityObjectJsonConverter.JsonSchemaModelEntity> deserializedSchemas)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | json reader to read from. |
| Model | baseModel | the base model entity to use. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | additionalTypes | types additional to the model. |
| ModelEntityBase | ownerModelEntity | the owning model entity of the relation. |
| System.Collections.Generic.Dictionary<System.String, EntityObjectJsonConverter.JsonSchemaModelEntity> | deserializedSchemas | already deserialized schemas. |
Returns
| Type | Description |
|---|---|
| EntityObjectJsonConverter.JsonSchemaRelation | Returns a new JsonSchemaRelation object. |
ReadSchemaRelationTargets(JsonReader, Model, Dictionary<String, ModelEntityBase>, List<EntityObjectJsonConverter.JsonSchemaModelEntity>, Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>)
Reads the targets of a SchemaRelation.
Declaration
public static void ReadSchemaRelationTargets(JsonReader reader, Model baseModel, Dictionary<string, ModelEntityBase> additionalTypes, List<EntityObjectJsonConverter.JsonSchemaModelEntity> targets, Dictionary<string, EntityObjectJsonConverter.JsonSchemaModelEntity> deserializedSchemas)
Parameters
| Type | Name | Description |
|---|---|---|
| Newtonsoft.Json.JsonReader | reader | the json reader to read from. |
| Model | baseModel | the base model for types. |
| System.Collections.Generic.Dictionary<System.String, ModelEntityBase> | additionalTypes | types additional to the model. |
| System.Collections.Generic.List<EntityObjectJsonConverter.JsonSchemaModelEntity> | targets | output target collection. |
| System.Collections.Generic.Dictionary<System.String, EntityObjectJsonConverter.JsonSchemaModelEntity> | deserializedSchemas | already deserialized schemas. |
WriteEntityObject(EntityObject, JsonWriter, HashSet<Guid>)
Write an EntityObject to the JsonWriter.
Declaration
public static void WriteEntityObject(EntityObject entityObject, JsonWriter writer, HashSet<Guid> writtenObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | entityObject | EntityObject to write. |
| Newtonsoft.Json.JsonWriter | writer | JsonWriter to write to. |
| System.Collections.Generic.HashSet<System.Guid> | writtenObjects | GUIDs of already written object. If null, related objects are serialized multiple times. |
WriteEntityObjectArray(IEnumerable<EntityObject>, JsonWriter, HashSet<Guid>)
Writes an Enumerable of EntityObjects to the JsonWriter.
Declaration
public static void WriteEntityObjectArray(IEnumerable<EntityObject> entityObjects, JsonWriter writer, HashSet<Guid> writtenObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<EntityObject> | entityObjects | EntityObjects to write. |
| Newtonsoft.Json.JsonWriter | writer | JsonWriter to write to. |
| System.Collections.Generic.HashSet<System.Guid> | writtenObjects | GUIDs of already written object. If null, related objects are serialized multiple times. |
WriteHomogenousEntityObject(EntityObject, EntityObjectJsonConverter.JsonSchemaModelEntity, JsonWriter, HashSet<Guid>)
Writes the homogenous entity object.
Declaration
public static void WriteHomogenousEntityObject(EntityObject eo, EntityObjectJsonConverter.JsonSchemaModelEntity schema, JsonWriter writer, HashSet<Guid> writtenObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObject | eo | The entity object to write. |
| EntityObjectJsonConverter.JsonSchemaModelEntity | schema | The schema to use for writing. |
| Newtonsoft.Json.JsonWriter | writer | The writer to write to. |
| System.Collections.Generic.HashSet<System.Guid> | writtenObjects | set containing the object uuids of the already written objects. |
WriteHomogenousEntityObjectArray(IEnumerable<EntityObject>, JsonWriter, HashSet<Guid>)
Writes an Enumerable of homogenious EntityObjects to the JsonWriter.
Declaration
public static void WriteHomogenousEntityObjectArray(IEnumerable<EntityObject> entityObjects, JsonWriter writer, HashSet<Guid> writtenObjects)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<EntityObject> | entityObjects | EntityObjects to write. |
| Newtonsoft.Json.JsonWriter | writer | JsonWriter to write to. |
| System.Collections.Generic.HashSet<System.Guid> | writtenObjects | GUIDs of already written object. If null, related objects are serialized multiple times. |
WriteSchema(EntityObjectJsonConverter.JsonSchemaModelEntity, JsonWriter, HashSet<EntityObjectJsonConverter.JsonSchemaModelEntity>)
Writes the schema.
Declaration
public static void WriteSchema(EntityObjectJsonConverter.JsonSchemaModelEntity schema, JsonWriter writer, HashSet<EntityObjectJsonConverter.JsonSchemaModelEntity> visitedModelEntities)
Parameters
| Type | Name | Description |
|---|---|---|
| EntityObjectJsonConverter.JsonSchemaModelEntity | schema | The schema. |
| Newtonsoft.Json.JsonWriter | writer | The writer. |
| System.Collections.Generic.HashSet<EntityObjectJsonConverter.JsonSchemaModelEntity> | visitedModelEntities | Lookup for already visited model entities. |