Class EntityProviderHandler
Resolve and register IEntity
Inheritance
Namespace: EPiServer.Data.Entity
Assembly: EPiServer.Data.dll
Version: 12.0.3Syntax
public class EntityProviderHandler : Object
Examples
Register an entity provider as follows:
[ModuleDependency(typeof(DataInitialization))]
public class EntityProviderRegistration : IInitializableModule
{
public void Initialize(Framework.Initialization.InitializationEngine context)
{
EntityProviderHandler.Instance.RegisterEntityProvider<MyEntityProvider, MyEntity>();
}
public void Uninitialize(Framework.Initialization.InitializationEngine context)
{
}
public void Preload(string[] parameters)
{
}
}
Resolve an entity provider as follows:
public void ResolveAnEntityProvider1()
{
IEntityProvider provider = EntityProviderHandler.Instance.GetEntityProvider<MyEntity>();
}
Register an entity provider as follows when the type is not known at compile-time:
public void ResolveAnEntityProvider1(Type type)
{
IEntityProvider provider = EntityProviderHandler.Instance.GetEntityProvider(type);
}
Constructors
EntityProviderHandler()
Initializes a new instance of this class.
Declaration
public EntityProviderHandler()
Properties
Instance
The globally available instance of the entity repository.
Declaration
public static EntityProviderHandler Instance { get; set; }
Property Value
Type | Description |
---|---|
Entity |
Remarks
This instance is being initialized by Data
Methods
GetEntityProvider(Type)
Gets the IEntity
Declaration
public virtual IEntityProvider GetEntityProvider(Type entityType)
Parameters
Type | Name | Description |
---|---|---|
System. |
entityType | The System. |
Returns
Type | Description |
---|---|
IEntity |
Returns an instance of the IEntity |
GetEntityProvider<TEntity>()
Gets the IEntity
Declaration
public virtual IEntityProvider GetEntityProvider<TEntity>()
where TEntity : IEntity
Returns
Type | Description |
---|---|
IEntity |
Returns an instance of the IEntity |
Type Parameters
Name | Description |
---|---|
TEntity | The type of the entity which you are requesting the provider for |
RegisterEntityProvider(IEntityProvider, Type[])
Registers a IEntity
Declaration
public virtual void RegisterEntityProvider(IEntityProvider entityProvider, params Type[] supportedTypes)
Parameters
Type | Name | Description |
---|---|---|
IEntity |
entityProvider | The instance of the IEntity |
System. |
supportedTypes | A list of System. |
RegisterEntityProvider<TEntityProvider, TSupportedType>()
Registers a IEntity
Declaration
public virtual void RegisterEntityProvider<TEntityProvider, TSupportedType>()
where TEntityProvider : IEntityProvider, new()
where TSupportedType : IEntity
Type Parameters
Name | Description |
---|---|
TEntityProvider | The instance of the IEntity |
TSupportedType | The System. |
Remarks
If an instance of TEntityProvider
is already added as a provider the TSupportedType
will point to the same instance.