27 lines
819 B
C#
27 lines
819 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace SmallInjector
|
|
{
|
|
/// <summary>
|
|
/// Wrapper for Service Locator
|
|
/// </summary>
|
|
public class ServiceLocatorWrapper : CommonServiceLocator.ServiceLocatorImplBase
|
|
{
|
|
private readonly IContainer _container;
|
|
|
|
/// <summary>
|
|
/// Creates new <see cref="ServiceLocatorWrapper"/> instance
|
|
/// </summary>
|
|
public ServiceLocatorWrapper(IContainer container)
|
|
{
|
|
_container = container;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override object DoGetInstance(Type serviceType, string key) => _container.Resolve(serviceType);
|
|
|
|
/// <inheritdoc />
|
|
protected override IEnumerable<object> DoGetAllInstances(Type serviceType) => _container.ResolveAny(serviceType);
|
|
}
|
|
} |