mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
fixed ninjet's race condition
This commit is contained in:
parent
b112e28b80
commit
30d38eead6
11 changed files with 259 additions and 63 deletions
|
@ -7,6 +7,7 @@ using NLog.Targets;
|
|||
using NzbDrone.Core.Entities;
|
||||
using NzbDrone.Core.Entities.Episode;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Fakes;
|
||||
using SubSonic.DataProviders;
|
||||
using SubSonic.Repository;
|
||||
using NLog;
|
||||
|
@ -15,24 +16,33 @@ namespace NzbDrone.Core
|
|||
{
|
||||
public static class CentralDispatch
|
||||
{
|
||||
private static IKernel _kernel;
|
||||
private static readonly Object kernelLock = new object();
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static void BindKernel(IKernel kernel)
|
||||
public static void BindKernel()
|
||||
{
|
||||
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db"));
|
||||
var provider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
||||
provider.Log = new SonicTrace();
|
||||
provider.LogParams = true;
|
||||
lock (kernelLock)
|
||||
{
|
||||
Logger.Debug("Binding Ninject's Kernel");
|
||||
_kernel = new StandardKernel();
|
||||
|
||||
kernel.Bind<ISeriesProvider>().To<SeriesProvider>().InSingletonScope();
|
||||
kernel.Bind<ISeasonProvider>().To<SeasonProvider>();
|
||||
kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>();
|
||||
kernel.Bind<IDiskProvider>().To<DiskProvider>();
|
||||
kernel.Bind<ITvDbProvider>().To<TvDbProvider>();
|
||||
kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope();
|
||||
kernel.Bind<INotificationProvider>().To<NotificationProvider>().InSingletonScope();
|
||||
kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();
|
||||
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db"));
|
||||
var provider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
||||
provider.Log = new SonicTrace();
|
||||
provider.LogParams = true;
|
||||
|
||||
ForceMigration(kernel.Get<IRepository>());
|
||||
_kernel.Bind<ISeriesProvider>().To<SeriesProvider>().InSingletonScope();
|
||||
_kernel.Bind<ISeasonProvider>().To<SeasonProvider>();
|
||||
_kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>();
|
||||
_kernel.Bind<IDiskProvider>().To<DiskProvider>();
|
||||
_kernel.Bind<ITvDbProvider>().To<TvDbProvider>();
|
||||
_kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope();
|
||||
_kernel.Bind<INotificationProvider>().To<FakeNotificationProvider>().InSingletonScope();
|
||||
_kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();
|
||||
|
||||
ForceMigration(_kernel.Get<IRepository>());
|
||||
}
|
||||
}
|
||||
|
||||
public static String AppPath
|
||||
|
@ -48,6 +58,19 @@ namespace NzbDrone.Core
|
|||
|
||||
}
|
||||
|
||||
public static IKernel NinjectKernel
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (_kernel == null)
|
||||
{
|
||||
BindKernel();
|
||||
}
|
||||
|
||||
return _kernel;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ConfigureNlog()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue