Class EntityCreator
Implements
Inherited Members
Namespace: LemonEdge.API.Entities
Assembly: LemonEdge.API.dll
Syntax
public class EntityCreator : IEntityCreator
Constructors
EntityCreator(IEntityDescriptorFactory, IFormulaFunctionsFactory, ILogger<EntityCreator>)
Declaration
public EntityCreator(IEntityDescriptorFactory descriptorFactory, IFormulaFunctionsFactory formulaFunctionsFactory, ILogger<EntityCreator> logger)
Parameters
Type | Name | Description |
---|---|---|
IEntityDescriptorFactory | descriptorFactory | |
IFormulaFunctionsFactory | formulaFunctionsFactory | |
ILogger<EntityCreator> | logger |
Methods
CanCreate(EntityDescriptor, UserInfo, IReadOnlyCache)
Returns true if the specified user has permissions to create the specified type of entity
Declaration
public Task<bool> CanCreate(EntityDescriptor forEntity, UserInfo userInfo, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
EntityDescriptor | forEntity | The type of entity to check if the user has permissions to create |
UserInfo | userInfo | The currently logged in user |
IReadOnlyCache | cache | A local cache |
Returns
Type | Description |
---|---|
Task<bool> | True if the specified user has permissions to create the specified type of entity |
CreateNewItem(Type, UserInfo, IReadOnlyCache, IEntityUpdater, bool, Action<IBaseEntity>?)
Creates a new instance of the specified entity ensuring all custom values, watchers and other processes are run against it where configured
Declaration
public Task<IBaseEntity> CreateNewItem(Type type, UserInfo userInfo, IReadOnlyCache cache, IEntityUpdater updater, bool logChange = true, Action<IBaseEntity>? onCreated = null)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The type of entity to create |
UserInfo | userInfo | The currently logged in user |
IReadOnlyCache | cache | A local cache |
IEntityUpdater | updater | The context this item should be created in. By default, the system will log the item as new, as well as any other new items/changes that occur due to this item being created (such as the creation of automatic watchers). If this is null then it can not fetch anything and so will not run any custom processes. |
bool | logChange | Whether this object should be logged with the supplied updater. The default is true. |
Action<IBaseEntity> | onCreated | An optional callback to call as soon as the object is created. |
Returns
Type | Description |
---|---|
Task<IBaseEntity> | A new instance of the specified entity ensuring all custom values, watchers and other processes are run against it where configured |
CreateNewItem<T>(UserInfo, IReadOnlyCache, IEntityUpdater, bool, Action<IBaseEntity>?)
A generic implementation of CreateNewItem(Type, UserInfo, IReadOnlyCache, IEntityUpdater, bool, Action<IBaseEntity>?)
Declaration
public Task<T> CreateNewItem<T>(UserInfo userInfo, IReadOnlyCache cache, IEntityUpdater updater, bool logChange = true, Action<IBaseEntity>? onCreated = null) where T : IBaseEntity
Parameters
Type | Name | Description |
---|---|---|
UserInfo | userInfo | |
IReadOnlyCache | cache | |
IEntityUpdater | updater | |
bool | logChange | |
Action<IBaseEntity> | onCreated |
Returns
Type | Description |
---|---|
Task<T> |
Type Parameters
Name | Description |
---|---|
T |
GetCloneContext(UserInfo, IReadOnlyCache, IEntityUpdater)
Returns a new clone context for use when cloning entities in the system
Declaration
public BaseEntityCloneContext GetCloneContext(UserInfo user, IReadOnlyCache cache, IEntityUpdater updater)
Parameters
Type | Name | Description |
---|---|---|
UserInfo | user | The currently logged on user to add to the context |
IReadOnlyCache | cache | A local cache |
IEntityUpdater | updater | The current context the item is to be cloned with |
Returns
Type | Description |
---|---|
BaseEntityCloneContext | A new clone context for use when cloning entities in the system |