Class ServiceLocatorComponentProvider
Provider that makes it possible to register a custom IComponent for a IComponentDefinition through the global IServiceLocator.
Inheritance
Inherited Members
Namespace: EPiServer.Shell.ViewComposition
Assembly: EPiServer.Shell.dll
Version: 8.11.0Syntax
[ComponentProvider]
public class ServiceLocatorComponentProvider : IComponentProvider, ISortable
Remarks
Configuration is done by registering a type for the service type IContainer with a specific name that matches the DefinitionName.
Examples
Example of how to replace component creation for the definition "FakeComponentDefinition" with the class "AnotherFakeComponent" in an initialization module:
context.Container.Configure(ce => { ce.For<IComponent>().Add<AnotherFakeComponent>().Named(new FakeComponentDefinition().DefinitionName); });
Constructors
ServiceLocatorComponentProvider(IServiceLocator)
Initializes a new instance of the ServiceLocatorComponentProvider class.
Declaration
public ServiceLocatorComponentProvider(IServiceLocator serviceLocator)
Parameters
Type | Name | Description |
---|---|---|
IServiceLocator | serviceLocator | The service locator. |
Properties
SortOrder
Used to select the order of execution of the IComponentProviders.
Declaration
public int SortOrder { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The sort order for this provider. |
Remarks
This provider has a sort order of 50.
Methods
CreateComponent(IComponentDefinition)
Try creating a component instance corresponding to an IComponentDefinition.
Declaration
public IComponent CreateComponent(IComponentDefinition definition)
Parameters
Type | Name | Description |
---|---|---|
IComponentDefinition | definition | The component definition to create a component for. |
Returns
Type | Description |
---|---|
IComponent |
|
GetComponentDefinitions()
Gets the components that this provider provides.
Declaration
public IEnumerable<IComponentDefinition> GetComponentDefinitions()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IComponentDefinition> | An System.Collections.Generic.IEnumerable<T> with the component definitions that this provider handles. |