mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-25 09:18:34 +00:00
36 lines
710 B
C#
36 lines
710 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Autofac;
|
|
using ServiceStack.Configuration;
|
|
|
|
namespace NzbDrone.Api
|
|
{
|
|
public class AutofacIocAdapter : IContainerAdapter
|
|
{
|
|
private readonly IContainer _container;
|
|
|
|
public AutofacIocAdapter(IContainer container)
|
|
{
|
|
_container = container;
|
|
}
|
|
|
|
public T Resolve<T>()
|
|
{
|
|
return _container.Resolve<T>();
|
|
}
|
|
|
|
public T TryResolve<T>()
|
|
{
|
|
T result;
|
|
|
|
if (_container.TryResolve<T>(out result))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
return default(T);
|
|
}
|
|
}
|
|
}
|