Class ServiceLocator
- Namespace
- Dynamicweb.Extensibility.Providers
- Assembly
- Dynamicweb.Core.dll
This class is a helper that provides a default implementation for most of the methods of IServiceLocator.
public abstract class ServiceLocator : IServiceLocator, IServiceProvider
- Inheritance
-
ServiceLocator
- Implements
- Derived
- Inherited Members
Methods
DoGetAllInstances(Type)
When implemented by inheriting classes, this method will do the actual work of resolving all the requested service instances.
protected abstract IEnumerable<object> DoGetAllInstances(Type serviceType)
Parameters
serviceType
TypeType of service requested.
Returns
- IEnumerable<object>
Sequence of service instance objects.
DoGetInstance(Type)
When implemented by inheriting classes, this method will do the actual work of resolving the requested service instance.
protected abstract object DoGetInstance(Type serviceType)
Parameters
serviceType
TypeType of instance requested.
Returns
- object
The requested service instance.
FormatActivationExceptionMessage(Exception, Type)
Format the exception message for use in an ActivationException that occurs while resolving a single service.
protected virtual string FormatActivationExceptionMessage(Exception actualException, Type serviceType)
Parameters
actualException
ExceptionThe actual exception thrown by the implementation.
serviceType
TypeType of service requested.
Returns
- string
The formatted exception message string.
GetAllInstances(Type)
Get all instances of the given serviceType
currently
registered in the container.
public virtual IEnumerable<object> GetAllInstances(Type serviceType)
Parameters
serviceType
TypeType of object requested.
Returns
- IEnumerable<object>
A sequence of instances of the requested
serviceType
.
Exceptions
- ActivationException
if there is are errors resolving the service instance.
GetAllInstances<TService>()
Get all instances of the given TService
currently
registered in the container.
public virtual IEnumerable<TService> GetAllInstances<TService>()
Returns
- IEnumerable<TService>
A sequence of instances of the requested
TService
.
Type Parameters
TService
Type of object requested.
Exceptions
- ActivationException
if there is are errors resolving the service instance.
GetInstance(Type)
Get an instance of the given serviceType
.
public virtual object GetInstance(Type serviceType)
Parameters
serviceType
TypeType of object requested.
Returns
- object
The requested service instance.
Exceptions
- ActivationException
if there is an error resolving the service instance.
GetInstance<TService>()
Get an instance of the given TService
.
public virtual TService GetInstance<TService>()
Returns
- TService
The requested service instance.
Type Parameters
TService
Type of object requested.
Exceptions
- ActivationException
if there is are errors resolving the service instance.
GetService(Type)
Implementation of GetService(Type).
public virtual object GetService(Type serviceType)
Parameters
serviceType
TypeThe requested service.
Returns
- object
The requested object.
Exceptions
- ActivationException
if there is an error in resolving the service instance.