Class ServiceLocatorExtensions
Extension methods for IServiceLocator
Inheritance
System.Object
ServiceLocatorExtensions
Namespace: EPiServer.ServiceLocation
Assembly: EPiServer.Framework.dll
Version: 12.0.3Syntax
public static class ServiceLocatorExtensions : Object
Methods
GetAllInstances<TService>(IServiceLocator)
Get all instances of the given TService
currently
registered in the container.
Declaration
public static IEnumerable<TService> GetAllInstances<TService>(this IServiceLocator serviceLocator)
Parameters
Type | Name | Description |
---|---|---|
IServiceLocator | serviceLocator |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TService> | A sequence of instances of the requested |
Type Parameters
Name | Description |
---|---|
TService | Type of object requested. |
Exceptions
Type | Condition |
---|---|
ActivationException | if there is are errors resolving the service instance. |
TryGetExistingInstance<TService>(IServiceLocator, out TService)
Tries to get an existing instance of the given TService
.
Declaration
public static bool TryGetExistingInstance<TService>(this IServiceLocator serviceLocator, out TService instance)
Parameters
Type | Name | Description |
---|---|---|
IServiceLocator | serviceLocator | The locator that is being extended |
TService | instance | The requested service instance or null if it do not exist |
Returns
Type | Description |
---|---|
System.Boolean | True if the instance was found |
Type Parameters
Name | Description |
---|---|
TService | Type of object requested. |
Exceptions
Type | Condition |
---|---|
ActivationException | if there is are errors resolving the service instance. |