Portable.CommonServiceLocator by Oren Novotny

<PackageReference Include="Portable.CommonServiceLocator" Version="1.2.2" />

 ServiceLocatorImplBase

This class is a helper that provides a default implementation for most of the methods of IServiceLocator.

protected abstract IEnumerable<object> DoGetAllInstances(Type serviceType)

When implemented by inheriting classes, this method will do the actual work of resolving all the requested service instances.

protected abstract object DoGetInstance(Type serviceType, string key)

When implemented by inheriting classes, this method will do the actual work of resolving the requested service instance.

protected virtual string FormatActivateAllExceptionMessage(Exception actualException, Type serviceType)

Format the exception message for use in an ActivationException that occurs while resolving multiple service instances.

protected virtual string FormatActivationExceptionMessage(Exception actualException, Type serviceType, string key)

Format the exception message for use in an ActivationException that occurs while resolving a single service.

public virtual IEnumerable<object> GetAllInstances(Type serviceType)

Get all instances of the given serviceType currently registered in the container.

public virtual IEnumerable<TService> GetAllInstances<TService>()

Get all instances of the given TService currently registered in the container.

public virtual object GetInstance(Type serviceType)

Get an instance of the given serviceType.

public virtual object GetInstance(Type serviceType, string key)

Get an instance of the given named serviceType.

public virtual TService GetInstance<TService>()

Get an instance of the given TService.

public virtual TService GetInstance<TService>(string key)

Get an instance of the given named TService.

public virtual object GetService(Type serviceType)

Implementation of GetService.