1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/NzbDrone/MainAppContainerBuilder.cs

58 lines
1.7 KiB
C#
Raw Normal View History

2013-04-20 03:05:48 +03:00
using System.IO;
using NLog;
using Nancy.Bootstrapper;
using NzbDrone.Api;
2013-05-06 00:24:33 +03:00
using NzbDrone.Api.SignalR;
2013-04-20 03:05:48 +03:00
using NzbDrone.Common;
2013-05-11 02:53:50 +03:00
using NzbDrone.Common.Composition;
2013-04-20 03:05:48 +03:00
using NzbDrone.Core.Datastore;
using NzbDrone.Core.ExternalNotification;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.RootFolders;
namespace NzbDrone
{
public class MainAppContainerBuilder : ContainerBuilderBase
{
private static readonly Logger Logger = LogManager.GetLogger("ContainerBuilderBase");
2013-05-11 02:53:50 +03:00
public static IContainer BuildContainer()
2013-04-20 03:05:48 +03:00
{
return new MainAppContainerBuilder().Container;
}
private MainAppContainerBuilder()
: base("NzbDrone", "NzbDrone.Common", "NzbDrone.Core", "NzbDrone.Api")
{
AutoRegisterImplementations<ExternalNotificationBase>();
2013-05-11 02:53:50 +03:00
AutoRegisterImplementations<NzbDronePersistentConnection>();
2013-04-20 03:05:48 +03:00
2013-05-11 02:53:50 +03:00
Container.Register(typeof(IBasicRepository<RootFolder>), typeof(BasicRepository<RootFolder>));
Container.Register(typeof(IBasicRepository<NamingConfig>), typeof(BasicRepository<NamingConfig>));
2013-04-20 03:05:48 +03:00
2013-05-11 02:53:50 +03:00
Container.Register<INancyBootstrapper, NancyBootstrapper>();
2013-05-06 00:24:33 +03:00
2013-04-20 03:05:48 +03:00
InitDatabase();
2013-05-11 02:53:50 +03:00
2013-04-20 03:05:48 +03:00
}
private void InitDatabase()
{
Logger.Info("Registering Database...");
//TODO: move this to factory
var environmentProvider = new EnvironmentProvider();
var appDataPath = environmentProvider.GetAppDataPath();
if (!Directory.Exists(appDataPath))
{
Directory.CreateDirectory(appDataPath);
}
2013-05-11 02:53:50 +03:00
Container.Register(c => c.Resolve<IDbFactory>().Create(environmentProvider.GetNzbDroneDatabase()));
2013-04-20 03:05:48 +03:00
}
}
}