Class EntityObjectJsonConverter
- Namespace
- TimeCockpit.Data.JsonConverters
- Assembly
- TimeCockpit.Data.dll
Custom serializer for EntityObjects into Json.
public class EntityObjectJsonConverter
- Inheritance
-
ObjectEntityObjectJsonConverter
- 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
readerJsonReaderJson reader.
modelModelData model.
environmentEnvironmentThe environment of the current datacontext used to validate permissions.
evaluateMissingDefaultValuesBoolean
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
readerJsonReaderThe reader.
anonymousTypesDictionary<String, ModelEntityBase>The anonymous types.
modelModelThe model.
environmentEnvironmentThe environment.
alreadyLoadedDictionary<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
objJObjectobj to read from.
anonymousTypesDictionary<String, ModelEntityBase>anonymous types for deserialization additionally to model.
modelModelThe current data context model
environmentEnvironmentCurrent DataContext environment.
alreadyLoadedDictionary<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
readerJsonReaderThe json reader.
anonymousTypesDictionary<String, ModelEntityBase>Anonymous types in a case of a Select New With query.
modelModelAn instance of Model that holds metadata.
environmentEnvironmentThe 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
readerJsonReaderjson reader to read an entity object from.
schemaEntityObjectJsonConverter.JsonSchemaModelEntityschema of the model entity.
entityObjectCacheDictionary<Guid, EntityObject>a dictionary containing the already parsed entity objects.
environmentEnvironmentenvironment for refreshing permissions.
modelModelthe model used for deserialization.
additionalTypesDictionary<String, ModelEntityBase>additional Types used for deserialization.
doneBooleanout 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
readerJsonReaderThe json reader to read an entity object collection from.
modelBaseModelmodel holding possible types.
additionalTypesDictionary<String, ModelEntityBase>additional types used for deserialization.
environmentEnvironmentthe 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
readerJsonReaderThe reader.
schemaEntityObjectJsonConverter.JsonSchemaModelEntitythe schema used for deserialization.
objectCacheDictionary<Guid, EntityObject>a cache holding references to already deserialized objects. used for relations.
environmentEnvironmentenvironment for refreshing permissions.
modelModelthe model used for deserialization.
additionalTypesDictionary<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
readerJsonReaderthe reader to read from.
baseModelModelbase model for data types.
additionalTypesDictionary<String, ModelEntityBase>types additional to the model.
deserializedSchemasDictionary<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
readerJsonReaderThe reader to read from.
modelEntityModelEntityBaseThe model entity.
baseModelModelbase model containing basic types.
additionalTypesDictionary<String, ModelEntityBase>additional data types for deserialization.
deserializedSchemasDictionary<String, EntityObjectJsonConverter.JsonSchemaModelEntity>already deserialized schemas.
propertiesList<EntityObjectJsonConverter.JsonSchemaProperty>The properties collection to insert properties into.
relationsList<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
readerJsonReaderjson reader to read from.
baseModelModelthe base model entity to use.
additionalTypesDictionary<String, ModelEntityBase>types additional to the model.
ownerModelEntityModelEntityBasethe owning model entity of the relation.
deserializedSchemasDictionary<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
readerJsonReaderthe json reader to read from.
baseModelModelthe base model for types.
additionalTypesDictionary<String, ModelEntityBase>types additional to the model.
targetsList<EntityObjectJsonConverter.JsonSchemaModelEntity>output target collection.
deserializedSchemasDictionary<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
entityObjectEntityObjectEntityObject to write.
writerJsonWriterJsonWriter to write to.
writtenObjectsHashSet<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
entityObjectsIEnumerable<EntityObject>EntityObjects to write.
writerJsonWriterJsonWriter to write to.
writtenObjectsHashSet<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
eoEntityObjectThe entity object to write.
schemaEntityObjectJsonConverter.JsonSchemaModelEntityThe schema to use for writing.
writerJsonWriterThe writer to write to.
writtenObjectsHashSet<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
entityObjectsIEnumerable<EntityObject>EntityObjects to write.
writerJsonWriterJsonWriter to write to.
writtenObjectsHashSet<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
schemaEntityObjectJsonConverter.JsonSchemaModelEntityThe schema.
writerJsonWriterThe writer.
visitedModelEntitiesHashSet<EntityObjectJsonConverter.JsonSchemaModelEntity>Lookup for already visited model entities.