SaaS CMS has officially launched! Learn more now.

Class ServiceLocatorComponentProvider

Provider that makes it possible to register a custom IComponent for a IComponentDefinition through the global IServiceLocator.

Inheritance
System.Object
ServiceLocatorComponentProvider
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Shell.ViewComposition
Assembly: EPiServer.Shell.dll
Version: 10.10.4
Syntax
[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

true if a component instance was created; otherwise false.

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.

Implements

Extension Methods