Class EntityProviderHandler
Resolve and register IEntityProvider implementations for .NET types
Inheritance
Inherited Members
Namespace: EPiServer.Data.Entity
Assembly: EPiServer.Data.dll
Version: 11.20.7Syntax
public class EntityProviderHandlerExamples
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 | 
|---|---|
| EntityProviderHandler | 
Remarks
This instance is being initialized by DataInitialization and will be null otherwise
Methods
GetEntityProvider(Type)
Gets the IEntityProvider that handles instantiation of the specified type
Declaration
public virtual IEntityProvider GetEntityProvider(Type entityType)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | entityType | The System.Type that is required to be supported by the returned IEntityProvider | 
Returns
| Type | Description | 
|---|---|
| IEntityProvider | Returns an instance of the IEntityProvider configured for the type requested in the
 | 
GetEntityProvider<TEntity>()
Gets the IEntityProvider that handles instantiation of the specified type
Declaration
public virtual IEntityProvider GetEntityProvider<TEntity>()
    where TEntity : IEntityReturns
| Type | Description | 
|---|---|
| IEntityProvider | Returns an instance of the IEntityProvider configured for the type requested in the
 | 
Type Parameters
| Name | Description | 
|---|---|
| TEntity | The type of the entity which you are requesting the provider for | 
RegisterEntityProvider(IEntityProvider, Type[])
Registers a IEntityProvider that handles instantiation of the specified type
Declaration
public virtual void RegisterEntityProvider(IEntityProvider entityProvider, params Type[] supportedTypes)Parameters
| Type | Name | Description | 
|---|---|---|
| IEntityProvider | entityProvider | The instance of the IEntityProvider configured for the types requested | 
| System.Type[] | supportedTypes | A list of System.Type that is supported by the IEntityProvider | 
RegisterEntityProvider<TEntityProvider, TSupportedType>()
Registers a IEntityProvider that handles instantiation of the specified type
Declaration
public virtual void RegisterEntityProvider<TEntityProvider, TSupportedType>()
    where TEntityProvider : IEntityProvider, new()
    where TSupportedType : IEntityType Parameters
| Name | Description | 
|---|---|
| TEntityProvider | The instance of the IEntityProvider configured for the type requested | 
| TSupportedType | The System.Type that is required to be supported by the IEntityProvider | 
Remarks
If an instance of TEntityProvider is already added as a provider the TSupportedType will point to the same instance.
