Class EntityDescriptorFactory
The main factory for creating and providing EntityDescriptor and ComplexTypeDescriptor for all items in the system including those defined by custom objects and addins
This automatically reloads whenever changes to custom objects or addins are detected within the system
Inherited Members
Namespace: LemonEdge.API.Descriptors
Assembly: LemonEdge.API.dll
Syntax
public class EntityDescriptorFactory : IEntityDescriptorFactoryLoader, IEntityDescriptorFactory
Constructors
EntityDescriptorFactory(EntityDescriptorFactoryOptions, ICodeBuilder, IReflectionHelper, IEntityWriter, IAssemblyManager, ILogger<EntityDescriptorFactory>)
Declaration
public EntityDescriptorFactory(EntityDescriptorFactoryOptions options, ICodeBuilder codeBuilder, IReflectionHelper reflector, IEntityWriter entityWriter, IAssemblyManager assemblyManager, ILogger<EntityDescriptorFactory> logger)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptorFactoryOptions | options | |
ICodeBuilder | codeBuilder | |
IReflectionHelper | reflector | |
IEntityWriter | entityWriter | |
IAssemblyManager | assemblyManager | |
ILogger<EntityDescriptorFactory> | logger |
Properties
Instance
Declaration
public static IEntityDescriptorFactory Instance { get; set; }
Property Value
Type | Description |
---|---|
IEntityDescriptorFactory |
IsLoaded
Returns whether this factory has any EntityDescriptors cached.
Declaration
public bool IsLoaded { get; }
Property Value
Type | Description |
---|---|
bool |
Loader
Declaration
public static IEntityDescriptorFactoryLoader Loader { get; }
Property Value
Type | Description |
---|---|
IEntityDescriptorFactoryLoader |
Options
Accessor for the configuration options for the factory.
Declaration
public EntityDescriptorFactoryOptions Options { get; set; }
Property Value
Type | Description |
---|---|
EntityDescriptorFactoryOptions |
Methods
CreateDescriptor()
Creates a default EntityDescriptor
Declaration
public EntityDescriptor CreateDescriptor()
Returns
Type | Description |
---|---|
EntityDescriptor |
GetComplexTypeDescriptor(Type)
Returns the ComplexTypeDescriptor for the specified instance of a complex type
Declaration
public ComplexTypeDescriptor GetComplexTypeDescriptor(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The complex type. |
Returns
Type | Description |
---|---|
ComplexTypeDescriptor | The ComplexTypeDescriptor for the specified instance of a complex type |
GetComplexTypes()
Returns a ComplexTypeDescriptor for every complex type found in the system including through custom objects and addins
Declaration
public IEnumerable<ComplexTypeDescriptor> GetComplexTypes()
Returns
Type | Description |
---|---|
IEnumerable<ComplexTypeDescriptor> | A ComplexTypeDescriptor for every complex type found in the system including through custom objects and addins |
GetDescriptor(IBaseEntity)
Returns the EntityDescriptor for the specified instance of an entity
Declaration
public EntityDescriptor GetDescriptor(IBaseEntity item)
Parameters
Type | Name | Description |
---|---|---|
IBaseEntity | item | The instance of an entity to return its associated entity descriptor for |
Returns
Type | Description |
---|---|
EntityDescriptor | The EntityDescriptor for the specified instance of an entity |
GetDescriptor(Guid, Guid)
Returns the EntityDescriptor for the specified type, and specified sub type (if looking for a replicated EntityDescriptor)
Declaration
public EntityDescriptor GetDescriptor(Guid id, Guid forType = default)
Parameters
Type | Name | Description |
---|---|---|
Guid | id | The unique global id of an entity type |
Guid | forType | The unique global id of an entity that is the sub type for the entity descriptor - used when looking for a replicated entity descriptor |
Returns
Type | Description |
---|---|
EntityDescriptor |
GetDescriptor(string)
Returns the EntityDescriptor for the specified uniqueKey of an EntityDescriptor
Declaration
public EntityDescriptor GetDescriptor(string uniqueKey)
Parameters
Type | Name | Description |
---|---|---|
string | uniqueKey | The UniqueKey of an entity descriptor |
Returns
Type | Description |
---|---|
EntityDescriptor | The EntityDescriptor for the specified uniqueKey of an EntityDescriptor |
GetDescriptor(Type, Guid)
Returns the EntityDescriptor for the specified type, and specified sub type (if looking for a replicated EntityDescriptor)
Declaration
public EntityDescriptor GetDescriptor(Type t, Guid forType = default)
Parameters
Type | Name | Description |
---|---|---|
Type | t | The type of an entity (either its interface or class type) |
Guid | forType | The unique global id of an entity that is the sub type for the entity descriptor - used when looking for a replicated entity descriptor |
Returns
Type | Description |
---|---|
EntityDescriptor |
GetDescriptor<T>(Guid)
Returns the EntityDescriptor for the specified type, and specified sub type (if looking for a replicated EntityDescriptor).
Declaration
public EntityDescriptor GetDescriptor<T>(Guid forType = default)
Parameters
Type | Name | Description |
---|---|---|
Guid | forType | The unique global id of an entity that is the sub type for the entity descriptor - used when looking for a replicated entity descriptor. |
Returns
Type | Description |
---|---|
EntityDescriptor |
Type Parameters
Name | Description |
---|---|
T | The type of an entity (either its interface or class type). |
GetDescriptors(Action)
Returns an EntityDescriptor for each entity within the system including those defined through custom objects and addins
This also includes replicated entity descriptors - in other words the complete set of all entity descriptors available within the system
Declaration
public IEnumerable<EntityDescriptor> GetDescriptors(Action callback = null)
Parameters
Type | Name | Description |
---|---|---|
Action | callback |
Returns
Type | Description |
---|---|
IEnumerable<EntityDescriptor> | An EntityDescriptor for each entity within the system including those defined through custom objects and addins |
GetDescriptors(IEnumerable<Assembly>)
re Returns all EntityDescriptor restricted to just those for a particular database.
This is required for task services and other processes that connect to multiple LemonEdge databases at once
Declaration
public IEnumerable<EntityDescriptor> GetDescriptors(IEnumerable<Assembly> customAssemblies)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Assembly> | customAssemblies | A list of custom assemblies to check. |
Returns
Type | Description |
---|---|
IEnumerable<EntityDescriptor> | All EntityDescriptor restricted to just those for a particular database. |
GetKnownTypes()
Returns all known entity types and enum types within all loaded entity descriptors in the system
Used for serialization
Declaration
public IEnumerable<Type> GetKnownTypes()
Returns
Type | Description |
---|---|
IEnumerable<Type> | All known entity types and enum types within all loaded entity descriptors in the system |
IsPartOfSpecificAssembly(Guid, IEnumerable<Assembly>)
It's possible using custom objects (which dynamically create dlls) that we have the same object design (using the same typeids -> sharedkey) in two databases we can only have one entity descriptor for that typeid, so we store any other assemblies that reference the same typeid then here we can say that if specific dlls are requested we can return that typeid if it is part of our stored assemblies
Declaration
public bool IsPartOfSpecificAssembly(Guid typeID, IEnumerable<Assembly> customAssemblies)
Parameters
Type | Name | Description |
---|---|---|
Guid | typeID | The unique global type of an entity that needs to be checked if it is defined in the list of assemblies |
IEnumerable<Assembly> | customAssemblies | A list of assemblies to check if the specified entity type is defined within it |
Returns
Type | Description |
---|---|
bool | True if the unique global id of the entity descriptor is defined as an entity in the specified list of assemblies |
ReplicateEntityDescriptor(EntityDescriptor, EntityDescriptor)
Declaration
public EntityDescriptor ReplicateEntityDescriptor(EntityDescriptor replicatingDescriptor, EntityDescriptor mainDescriptor)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | replicatingDescriptor | |
EntityDescriptor | mainDescriptor |
Returns
Type | Description |
---|---|
EntityDescriptor |