2013-05-06 00:24:33 +03:00
|
|
|
using System;
|
|
|
|
using Microsoft.AspNet.SignalR;
|
2013-07-27 03:05:33 +03:00
|
|
|
using Microsoft.AspNet.SignalR.Infrastructure;
|
2013-05-11 02:53:50 +03:00
|
|
|
using NzbDrone.Common.Composition;
|
2013-05-06 00:24:33 +03:00
|
|
|
|
2013-09-11 09:33:47 +03:00
|
|
|
namespace NzbDrone.SignalR
|
2013-05-06 00:24:33 +03:00
|
|
|
{
|
|
|
|
public class SignalrDependencyResolver : DefaultDependencyResolver
|
|
|
|
{
|
2013-05-11 02:53:50 +03:00
|
|
|
private readonly IContainer _container;
|
2013-05-06 00:24:33 +03:00
|
|
|
|
2013-05-11 02:53:50 +03:00
|
|
|
public static void Register(IContainer container)
|
2013-05-06 00:24:33 +03:00
|
|
|
{
|
|
|
|
GlobalHost.DependencyResolver = new SignalrDependencyResolver(container);
|
|
|
|
}
|
|
|
|
|
2013-05-11 02:53:50 +03:00
|
|
|
private SignalrDependencyResolver(IContainer container)
|
2013-05-06 00:24:33 +03:00
|
|
|
{
|
2013-07-27 03:05:33 +03:00
|
|
|
container.RegisterSingleton(typeof(IPerformanceCounterManager), typeof(NoOpPerformanceCounterManager));
|
2013-05-06 00:24:33 +03:00
|
|
|
_container = container;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override object GetService(Type serviceType)
|
|
|
|
{
|
2013-05-11 02:53:50 +03:00
|
|
|
if (_container.IsTypeRegistered(serviceType))
|
|
|
|
{
|
|
|
|
return _container.Resolve(serviceType);
|
|
|
|
}
|
2013-05-06 00:24:33 +03:00
|
|
|
|
2013-05-11 02:53:50 +03:00
|
|
|
return base.GetService(serviceType);
|
2013-05-06 00:24:33 +03:00
|
|
|
}
|
|
|
|
}
|
2013-07-27 03:05:33 +03:00
|
|
|
}
|