mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
33 lines
964 B
C#
33 lines
964 B
C#
|
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)
|
|||
|
.AsImplementedInterfaces()
|
|||
|
.SingleInstance();
|
|||
|
|
|||
|
containerBuilder.RegisterAssemblyTypes(apiAssembly)
|
|||
|
.AsSelf()
|
|||
|
.SingleInstance();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|