1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 12:32:31 +01:00
Radarr/NzbDrone.Api/TinyIoCDependencyResolver.cs
2013-04-02 19:20:05 -07:00

40 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using SignalR;
using TinyIoC;
namespace NzbDrone.Api
{
public class TinyIoCDependencyResolver : DefaultDependencyResolver
{
private readonly TinyIoCContainer _container;
public TinyIoCDependencyResolver(TinyIoCContainer container)
{
_container = container;
}
public override object GetService(Type serviceType)
{
if (_container.CanResolve(serviceType))
{
return _container.Resolve(serviceType);
}
return base.GetService(serviceType);
}
public override IEnumerable<object> GetServices(Type serviceType)
{
IEnumerable<object> services = new object[] { };
if (_container.CanResolve(serviceType))
{
services = _container.ResolveAll(serviceType);
}
return services.Concat(base.GetServices(serviceType));
}
}
}