Table of Contents

Class EntityObjectJsonConverter

Namespace
TimeCockpit.Data.JsonConverters
Assembly
TimeCockpit.Data.dll

Custom serializer for EntityObjects into Json.

public class EntityObjectJsonConverter
Inheritance
Object
EntityObjectJsonConverter
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()

Constructors

EntityObjectJsonConverter()

public EntityObjectJsonConverter()

Methods

CreateEntityObjectFromPrototype(JsonReader, Model, Environment, Boolean)

Create an entity object from a json prototype (igoring missing members etc.).

public static EntityObject CreateEntityObjectFromPrototype(JsonReader reader, Model model, Environment environment, bool evaluateMissingDefaultValues)

Parameters

reader JsonReader

Json reader.

model Model

Data model.

environment Environment

The environment of the current datacontext used to validate permissions.

evaluateMissingDefaultValues Boolean

Returns

EntityObject

New entity object from prototype.

ReadEntityObject(JsonReader, Dictionary<String, ModelEntityBase>, Model, Environment, Dictionary<Guid, EntityObject>)

Reads the entity object.

public static EntityObject ReadEntityObject(JsonReader reader, Dictionary<string, ModelEntityBase> anonymousTypes, Model model, Environment environment, Dictionary<Guid, EntityObject> alreadyLoaded)

Parameters

reader JsonReader

The reader.

anonymousTypes Dictionary<String, ModelEntityBase>

The anonymous types.

model Model

The model.

environment Environment

The environment.

alreadyLoaded Dictionary<Guid, EntityObject>

Previously loaded entity objects (for relations)

Returns

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

public static EntityObject ReadEntityObject(JObject obj, Dictionary<string, ModelEntityBase> anonymousTypes, Model model, Environment environment, Dictionary<Guid, EntityObject> alreadyLoaded)

Parameters

obj JObject

obj to read from.

anonymousTypes Dictionary<String, ModelEntityBase>

anonymous types for deserialization additionally to model.

model Model

The current data context model

environment Environment

Current DataContext environment.

alreadyLoaded Dictionary<Guid, EntityObject>

already loaded entity objects.

Returns

EntityObject

an instance of EntityObject

ReadEntityObjectArray(JsonReader, Dictionary<String, ModelEntityBase>, Model, Environment)

Reads the EntityObjects out of an array of EntityObjects.

public static List<EntityObject> ReadEntityObjectArray(JsonReader reader, Dictionary<string, ModelEntityBase> anonymousTypes, Model model, Environment environment)

Parameters

reader JsonReader

The json reader.

anonymousTypes Dictionary<String, ModelEntityBase>

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

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.

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

reader JsonReader

json reader to read an entity object from.

schema EntityObjectJsonConverter.JsonSchemaModelEntity

schema of the model entity.

entityObjectCache Dictionary<Guid, EntityObject>

a dictionary containing the already parsed entity objects.

environment Environment

environment for refreshing permissions.

model Model

the model used for deserialization.

additionalTypes Dictionary<String, ModelEntityBase>

additional Types used for deserialization.

done Boolean

out param indicating whether we're done reading

Returns

EntityObject

returns an entityobject serialized from the reader.

ReadHomogenousEntityObjectArray(JsonReader, Model, Dictionary<String, ModelEntityBase>, Environment)

Reads the homogenous entity object array.

public static IEnumerable<EntityObject> ReadHomogenousEntityObjectArray(JsonReader reader, Model modelBase, Dictionary<string, ModelEntityBase> additionalTypes, Environment environment)

Parameters

reader JsonReader

The json reader to read an entity object collection from.

modelBase Model

model holding possible types.

additionalTypes Dictionary<String, ModelEntityBase>

additional types used for deserialization.

environment Environment

the environment for refreshing permissions.

Returns

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.

public static IEnumerable<EntityObject> ReadHomogenousEntityObjectArrayValues(JsonReader reader, EntityObjectJsonConverter.JsonSchemaModelEntity schema, Dictionary<Guid, EntityObject> objectCache, Environment environment, Model model, Dictionary<string, ModelEntityBase> additionalTypes)

Parameters

reader JsonReader

The reader.

schema EntityObjectJsonConverter.JsonSchemaModelEntity

the schema used for deserialization.

objectCache Dictionary<Guid, EntityObject>

a cache holding references to already deserialized objects. used for relations.

environment Environment

environment for refreshing permissions.

model Model

the model used for deserialization.

additionalTypes Dictionary<String, ModelEntityBase>

additional types used for deserialization.

Returns

IEnumerable<EntityObject>

the deserialized entity objects.

ReadSchema(JsonReader, Model, Dictionary<String, ModelEntityBase>, Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>)

Reads the schema from a json reader.

public static EntityObjectJsonConverter.JsonSchemaModelEntity ReadSchema(JsonReader reader, Model baseModel, Dictionary<string, ModelEntityBase> additionalTypes, Dictionary<string, EntityObjectJsonConverter.JsonSchemaModelEntity> deserializedSchemas)

Parameters

reader JsonReader

the reader to read from.

baseModel Model

base model for data types.

additionalTypes Dictionary<String, ModelEntityBase>

types additional to the model.

deserializedSchemas Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>

already deserialized schemas.

Returns

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

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

reader JsonReader

The reader to read from.

modelEntity ModelEntityBase

The model entity.

baseModel Model

base model containing basic types.

additionalTypes Dictionary<String, ModelEntityBase>

additional data types for deserialization.

deserializedSchemas Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>

already deserialized schemas.

properties List<EntityObjectJsonConverter.JsonSchemaProperty>

The properties collection to insert properties into.

relations List<EntityObjectJsonConverter.JsonSchemaRelation>

The relations collection to insert relations into.

ReadSchemaRelation(JsonReader, Model, Dictionary<String, ModelEntityBase>, ModelEntityBase, Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>)

Reads the schema of a relation.

public static EntityObjectJsonConverter.JsonSchemaRelation ReadSchemaRelation(JsonReader reader, Model baseModel, Dictionary<string, ModelEntityBase> additionalTypes, ModelEntityBase ownerModelEntity, Dictionary<string, EntityObjectJsonConverter.JsonSchemaModelEntity> deserializedSchemas)

Parameters

reader JsonReader

json reader to read from.

baseModel Model

the base model entity to use.

additionalTypes Dictionary<String, ModelEntityBase>

types additional to the model.

ownerModelEntity ModelEntityBase

the owning model entity of the relation.

deserializedSchemas Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>

already deserialized schemas.

Returns

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.

public static void ReadSchemaRelationTargets(JsonReader reader, Model baseModel, Dictionary<string, ModelEntityBase> additionalTypes, List<EntityObjectJsonConverter.JsonSchemaModelEntity> targets, Dictionary<string, EntityObjectJsonConverter.JsonSchemaModelEntity> deserializedSchemas)

Parameters

reader JsonReader

the json reader to read from.

baseModel Model

the base model for types.

additionalTypes Dictionary<String, ModelEntityBase>

types additional to the model.

targets List<EntityObjectJsonConverter.JsonSchemaModelEntity>

output target collection.

deserializedSchemas Dictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>

already deserialized schemas.

WriteEntityObject(EntityObject, JsonWriter, HashSet<Guid>)

Write an EntityObject to the JsonWriter.

public static void WriteEntityObject(EntityObject entityObject, JsonWriter writer, HashSet<Guid> writtenObjects)

Parameters

entityObject EntityObject

EntityObject to write.

writer JsonWriter

JsonWriter to write to.

writtenObjects HashSet<Guid>

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.

public static void WriteEntityObjectArray(IEnumerable<EntityObject> entityObjects, JsonWriter writer, HashSet<Guid> writtenObjects)

Parameters

entityObjects IEnumerable<EntityObject>

EntityObjects to write.

writer JsonWriter

JsonWriter to write to.

writtenObjects HashSet<Guid>

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.

public static void WriteHomogenousEntityObject(EntityObject eo, EntityObjectJsonConverter.JsonSchemaModelEntity schema, JsonWriter writer, HashSet<Guid> writtenObjects)

Parameters

eo EntityObject

The entity object to write.

schema EntityObjectJsonConverter.JsonSchemaModelEntity

The schema to use for writing.

writer JsonWriter

The writer to write to.

writtenObjects HashSet<Guid>

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.

public static void WriteHomogenousEntityObjectArray(IEnumerable<EntityObject> entityObjects, JsonWriter writer, HashSet<Guid> writtenObjects)

Parameters

entityObjects IEnumerable<EntityObject>

EntityObjects to write.

writer JsonWriter

JsonWriter to write to.

writtenObjects HashSet<Guid>

GUIDs of already written object. If null, related objects are serialized multiple times.

WriteSchema(EntityObjectJsonConverter.JsonSchemaModelEntity, JsonWriter, HashSet<EntityObjectJsonConverter.JsonSchemaModelEntity>)

Writes the schema.

public static void WriteSchema(EntityObjectJsonConverter.JsonSchemaModelEntity schema, JsonWriter writer, HashSet<EntityObjectJsonConverter.JsonSchemaModelEntity> visitedModelEntities)

Parameters

schema EntityObjectJsonConverter.JsonSchemaModelEntity

The schema.

writer JsonWriter

The writer.

visitedModelEntities HashSet<EntityObjectJsonConverter.JsonSchemaModelEntity>

Lookup for already visited model entities.