Removed duplicated code from ContainerBuilders

pull/1603/head
Keivan Beigi 8 years ago
parent 8252a2a60f
commit 6ae5829439

@ -13,12 +13,15 @@ namespace NzbDrone.Common.Composition
{ {
private readonly List<Type> _loadedTypes; private readonly List<Type> _loadedTypes;
public IContainer Container { get; private set; } protected IContainer Container { get; }
protected ContainerBuilderBase(IStartupContext args, params string[] assemblies) protected ContainerBuilderBase(IStartupContext args, List<string> assemblies)
{ {
_loadedTypes = new List<Type>(); _loadedTypes = new List<Type>();
assemblies.Add(OsInfo.IsWindows ? "NzbDrone.Windows" : "NzbDrone.Mono");
assemblies.Add("NzbDrone.Common");
foreach (var assembly in assemblies) foreach (var assembly in assemblies)
{ {
_loadedTypes.AddRange(Assembly.Load(assembly).GetTypes()); _loadedTypes.AddRange(Assembly.Load(assembly).GetTypes());

@ -15,26 +15,15 @@ namespace NzbDrone.Host
var assemblies = new List<string> var assemblies = new List<string>
{ {
"NzbDrone.Host", "NzbDrone.Host",
"NzbDrone.Common",
"NzbDrone.Core", "NzbDrone.Core",
"NzbDrone.Api", "NzbDrone.Api",
"NzbDrone.SignalR" "NzbDrone.SignalR"
}; };
if (OsInfo.IsWindows) return new MainAppContainerBuilder(args, assemblies).Container;
{
assemblies.Add("NzbDrone.Windows");
}
else
{
assemblies.Add("NzbDrone.Mono");
}
return new MainAppContainerBuilder(args, assemblies.ToArray()).Container;
} }
private MainAppContainerBuilder(StartupContext args, string[] assemblies) private MainAppContainerBuilder(StartupContext args, List<string> assemblies)
: base(args, assemblies) : base(args, assemblies)
{ {
AutoRegisterImplementations<NzbDronePersistentConnection>(); AutoRegisterImplementations<NzbDronePersistentConnection>();

@ -7,7 +7,7 @@ namespace NzbDrone.Update
{ {
public class UpdateContainerBuilder : ContainerBuilderBase public class UpdateContainerBuilder : ContainerBuilderBase
{ {
private UpdateContainerBuilder(IStartupContext startupContext, string[] assemblies) private UpdateContainerBuilder(IStartupContext startupContext, List<string> assemblies)
: base(startupContext, assemblies) : base(startupContext, assemblies)
{ {
Container.Register<IHttpDispatcher, FallbackHttpDispatcher>(); Container.Register<IHttpDispatcher, FallbackHttpDispatcher>();
@ -17,22 +17,10 @@ namespace NzbDrone.Update
{ {
var assemblies = new List<string> var assemblies = new List<string>
{ {
"NzbDrone.Update", "NzbDrone.Update"
"NzbDrone.Common"
}; };
if (OsInfo.IsWindows) return new UpdateContainerBuilder(startupContext, assemblies).Container;
{
assemblies.Add("NzbDrone.Windows");
}
else
{
assemblies.Add("NzbDrone.Mono");
}
return new UpdateContainerBuilder(startupContext, assemblies.ToArray()).Container;
} }
} }
} }
Loading…
Cancel
Save