Class ServiceLocatorComponentProvider
Provider that makes it possible to register a custom IComponent for a IComponent
Inheritance
Inherited Members
Namespace: EPiServer.Shell.ViewComposition
Assembly: EPiServer.Shell.dll
Version: 7.19.2Syntax
[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 Definition
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 Service
Declaration
public ServiceLocatorComponentProvider(IServiceLocator serviceLocator)
Parameters
Type | Name | Description |
---|---|---|
IService |
serviceLocator | The service locator. |
Properties
SortOrder
Used to select the order of execution of the IComponent
Declaration
public int SortOrder { get; }
Property Value
Type | Description |
---|---|
System. |
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 IComponent
Declaration
public IComponent CreateComponent(IComponentDefinition definition)
Parameters
Type | Name | Description |
---|---|---|
IComponent |
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. |
An System.Collections.Generic.IEnumerable<T> with the component definitions that this provider handles. |