2013-02-19 01:57:08 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Autofac;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Common
|
|
|
|
|
{
|
|
|
|
|
public static class CommonContainerExtensions
|
|
|
|
|
{
|
|
|
|
|
public static void RegisterCommonServices(this ContainerBuilder containerBuilder)
|
|
|
|
|
{
|
|
|
|
|
containerBuilder.RegisterAssemblyTypes("NzbDrone.Common");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RegisterAssemblyTypes(this ContainerBuilder containerBuilder, string assemblyName)
|
|
|
|
|
{
|
|
|
|
|
var apiAssembly = Assembly.Load(assemblyName);
|
|
|
|
|
|
|
|
|
|
if (apiAssembly == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ApplicationException("Couldn't load assembly " + assemblyName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
2013-03-30 22:14:33 +00:00
|
|
|
|
.AsImplementedInterfaces();
|
2013-02-19 01:57:08 +00:00
|
|
|
|
|
|
|
|
|
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
2013-03-30 22:14:33 +00:00
|
|
|
|
.AsSelf();
|
2013-02-19 01:57:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|