Class ServiceLocatorExtensions
Extension methods for IServiceLocator
Inheritance
System.Object
ServiceLocatorExtensions
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.ServiceLocation
Assembly: EPiServer.Framework.dll
Version: 11.20.7Syntax
public static class ServiceLocatorExtensions
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. |