Class InitializationEngine
Used internally by EPiServer to initialize a set of modules
Inheritance
Implements
Namespace: EPiServer.Framework.Initialization
Assembly: EPiServer.Framework.dll
Version: 12.0.3Syntax
public class InitializationEngine : Object, IInitializationEngine
Constructors
InitializationEngine()
Constructor used for testing and outside-the-web purposes.
Declaration
public InitializationEngine()
InitializationEngine(IServiceCollection)
Constructor used when service locator and service configuration provider is created from passed in factory
Declaration
public InitializationEngine(IServiceCollection services)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | The service collection. |
Remarks
Will initialize the application as WebApplication
InitializationEngine(IServiceCollection, HostType)
Constructor used when service locator and service configuration provider is created from passed in factory
Declaration
public InitializationEngine(IServiceCollection services, HostType hostType)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | The service collection. |
HostType | hostType | Specifies which hosttype the application should be initialized as |
InitializationEngine(IServiceCollection, HostType, IEnumerable<Assembly>)
Constructor used when service locator and service configuration provider is created from passed in factory and scanning is done from explicit specified assemblies
Declaration
public InitializationEngine(IServiceCollection services, HostType hostType, IEnumerable<Assembly> assemblies)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | The service collection. |
HostType | hostType | Specifies which hosttype the application should be initialized as |
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | The assemblies to scan |
InitializationEngine(IServiceCollection, IEnumerable<IInitializableModule>, HostType, IEnumerable<Assembly>, IAssemblyScanner)
Constructor used for testing and outside-the-web purposes, not intended for public use
Declaration
public InitializationEngine(IServiceCollection services, IEnumerable<IInitializableModule> modules, HostType hostType, IEnumerable<Assembly> assemblies, IAssemblyScanner assemblyScanner)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Extensions.DependencyInjection.IServiceCollection | services | The service collection. |
System.Collections.Generic.IEnumerable<IInitializableModule> | modules | The list of modules to initialize using this engine. |
HostType | hostType | The type of host this engine initializes. |
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | A list of assemblies that can be scanned as part of initialization |
IAssemblyScanner | assemblyScanner | The assembly scanner |
InitializationEngine(IEnumerable<IInitializableModule>, HostType)
Constructor used for testing and outside-the-web purposes.
Declaration
public InitializationEngine(IEnumerable<IInitializableModule> modules, HostType hostType)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IInitializableModule> | modules | The list of modules to initialize using this engine. |
HostType | hostType | The type of host this engine initializes. |
InitializationEngine(IEnumerable<IInitializableModule>, HostType, IEnumerable<Assembly>)
Constructor used for testing and outside-the-web purposes.
Declaration
public InitializationEngine(IEnumerable<IInitializableModule> modules, HostType hostType, IEnumerable<Assembly> assemblies)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IInitializableModule> | modules | The list of modules to initialize using this engine. |
HostType | hostType | The type of host this engine initializes. |
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | A list of assemblies that can be scanned as part of initialization |
Properties
Assemblies
A list of assemblies that should participate in the initialization
Declaration
public IEnumerable<Assembly> Assemblies { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> |
Remarks
This list will be the base for different scanning operations done within the initialization such as plug-in systems and services configured using ServiceConfigurationAttribute, it is also used if ScanAssemblies() is called to automatically populate the list of assemblies.
By default when EPiServer initializes this will be set to a list of allowed assemblies configured in EPiServer.Framework.Initialization.InitializationModule.Assemblies
HostType
The HostType of the current application
Declaration
public HostType HostType { get; }
Property Value
Type | Description |
---|---|
HostType |
InitializationState
Gets or sets the state of the initialization.
Declaration
public InitializationState InitializationState { get; protected set; }
Property Value
Type | Description |
---|---|
InitializationState | The state of the initialization. |
Locate
Provides access to the DI container
Declaration
public ServiceProviderHelper Locate { get; set; }
Property Value
Type | Description |
---|---|
ServiceProviderHelper |
Modules
The list of modules that should be initialized
Declaration
public virtual IEnumerable<IInitializableModule> Modules { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IInitializableModule> |
Remarks
You can automatically populate this list by calling ScanAssemblies()
Methods
BuildTypeScanner()
Builds a ITypeScannerLookup from configured assemblies and modules
Declaration
public virtual ITypeScannerLookup BuildTypeScanner()
Returns
Type | Description |
---|---|
ITypeScannerLookup | A type scanner lookup |
Configure()
Calls all IConfigurableModule instances.
Declaration
public void Configure()
ConfigureModules(IEnumerable<IInitializableModule>)
Calls all IConfigurableModule instances.
Declaration
public virtual void ConfigureModules(IEnumerable<IInitializableModule> modules)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IInitializableModule> | modules |
GetDependencySortedModules()
Gets the list of initialization modules sorted by dependencies.
Declaration
public IList<IInitializableModule> GetDependencySortedModules()
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<IInitializableModule> | A list of IInitializableModule. |
Initialize()
Initializes all initializable modules.
Declaration
public void Initialize()
InitializeModules()
Initializes the modules.
Declaration
protected void InitializeModules()
IsInitialized(IInitializableModule)
Determines whether the specified module is initialized.
Declaration
public bool IsInitialized(IInitializableModule module)
Parameters
Type | Name | Description |
---|---|---|
IInitializableModule | module | The module. |
Returns
Type | Description |
---|---|
System.Boolean |
|
OnInitComplete()
Called when initialization is complete to raise the InitComplete event.
Declaration
public void OnInitComplete()
Remarks
The invocation of the InitComplete event is a bit special. In order to support the same kind of "retry on exception" semantics as for the Initialize(InitializationEngine) method, we simply remove the delegate from the event handler once it has executed successfully (i.e. without throwing an exception).
ScanAssemblies()
Scans the list of assemblies for initialization modules
Declaration
public void ScanAssemblies()
Uninitialize()
Un-initialize all initializable modules.
Declaration
public void Uninitialize()
Events
InitComplete
InitComplete is raised when initialization is complete.
Declaration
public event EventHandler InitComplete
Event Type
Type | Description |
---|---|
System.EventHandler |
Remarks
Initialization is complete when all intializable modules have executed successfully (without throwing any exception).