Class ServiceLocator
- Namespace
- Dynamicweb.Extensibility.Providers
- Assembly
- Dynamicweb.Extensibility.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
- 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
serviceTypeType- Type of service requested.
Returns
- IEnumerable<object>
- Sequence of service instance objects.
DoGetInstance(Type, string)
When implemented by inheriting classes, this method will do the actual work of resolving
the requested service instance.
protected abstract object DoGetInstance(Type serviceType, string key)
Parameters
serviceTypeType- Type of instance requested.
keystring- Name of registered service you want. May be null.
Returns
- object
- The requested service instance.
FormatActivateAllExceptionMessage(Exception, Type)
Format the exception message for use in an ActivationException
that occurs while resolving multiple service instances.
[Obsolete("Use FormatActivationExceptionMessage instead.")]
protected virtual string FormatActivateAllExceptionMessage(Exception actualException, Type serviceType)
Parameters
actualExceptionException- The actual exception thrown by the implementation.
serviceTypeType- Type of service requested.
Returns
- string
- The formatted exception message string.
FormatActivationExceptionMessage(Exception, Type, string)
Format the exception message for use in an ActivationException
that occurs while resolving a single service.
protected virtual string FormatActivationExceptionMessage(Exception actualException, Type serviceType, string key)
Parameters
actualExceptionException- The actual exception thrown by the implementation.
serviceTypeType- Type of service requested.
keystring- Name 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
serviceTypeType- Type 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
serviceTypeType- Type of object requested.
Returns
- object
- The requested service instance.
Exceptions
- ActivationException
- if there is an error resolving the service instance.
GetInstance(Type, string)
Get an instance of the given named
serviceType.public virtual object GetInstance(Type serviceType, string key)
Parameters
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.
GetInstance<TService>(string)
Get an instance of the given named
TService.public virtual TService GetInstance<TService>(string key)
Parameters
keystring- Name the object was registered with.
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
serviceTypeType- The requested service.
Returns
- object
- The requested object.
Exceptions
- ActivationException
- if there is an error in resolving the service instance.