event aggregator is singleton to prevent it from being disposed.

This commit is contained in:
kay.one 2013-03-30 15:43:19 -07:00
parent f2886d89de
commit af3282630f
6 changed files with 26 additions and 6 deletions

View File

@ -26,7 +26,7 @@ namespace NzbDrone.Common.Eventing
{ {
_logger.Debug("{0} -> {1}", message.GetType().Name, handler.GetType().Name); _logger.Debug("{0} -> {1}", message.GetType().Name, handler.GetType().Name);
handler.Handle(message); handler.Handle(message);
_logger.Debug("{0} -#> {1}", message.GetType().Name, handler.GetType().Name); _logger.Debug("{0} <- {1}", message.GetType().Name, handler.GetType().Name);
} }
@ -37,7 +37,7 @@ namespace NzbDrone.Common.Eventing
{ {
_logger.Debug("{0} ~> {1}", message.GetType().Name, handlerLocal.GetType().Name); _logger.Debug("{0} ~> {1}", message.GetType().Name, handlerLocal.GetType().Name);
handlerLocal.HandleAsync(message); handlerLocal.HandleAsync(message);
_logger.Debug("{0} ~#> {1}", message.GetType().Name, handlerLocal.GetType().Name); _logger.Debug("{0} <~ {1}", message.GetType().Name, handlerLocal.GetType().Name);
}); });
} }
} }

View File

@ -245,7 +245,7 @@
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\SabProviderFixture.cs" /> <Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\SabProviderFixture.cs" />
<Compile Include="ProviderTests\SceneMappingProviderTest.cs" /> <Compile Include="ProviderTests\SceneMappingProviderTest.cs" />
<Compile Include="TvTests\SeriesProviderTest.cs" /> <Compile Include="TvTests\SeriesProviderTest.cs" />
<Compile Include="ProviderTests\TvDbProviderTest.cs" /> <Compile Include="ProviderTests\TvDbProxyFixture.cs" />
<Compile Include="XbmcVersionTests.cs" /> <Compile Include="XbmcVersionTests.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
[TestFixture] [TestFixture]
public class TvDbProviderTest : CoreTest<TvDbProxy> public class TvDbProxyFixture : CoreTest<TvDbProxy>
{ {
[TestCase("The Simpsons")] [TestCase("The Simpsons")]
[TestCase("Family Guy")] [TestCase("Family Guy")]
@ -50,5 +50,12 @@ namespace NzbDrone.Core.Test.ProviderTests
details.Should().NotBeNull(); details.Should().NotBeNull();
details.Covers.Value.Should().NotBeEmpty(); details.Covers.Value.Should().NotBeEmpty();
} }
[Test]
public void should_be_able_to_get_list_of_episodes()
{
var details = Subject.GetEpisodes(75978);
details.Should().NotBeEmpty();
}
} }
} }

View File

@ -4,6 +4,7 @@ using System.Reflection;
using Autofac; using Autofac;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Common.Eventing;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.ExternalNotification; using NzbDrone.Core.ExternalNotification;
using NzbDrone.Core.IndexerSearch; using NzbDrone.Core.IndexerSearch;
@ -23,7 +24,11 @@ namespace NzbDrone.Core
containerBuilder.RegisterAssembly("NzbDrone.Core"); containerBuilder.RegisterAssembly("NzbDrone.Core");
containerBuilder.InitDatabase(); containerBuilder.InitDatabase();
containerBuilder.RegisterType<EventAggregator>()
.As<IEventAggregator>().SingleInstance();
containerBuilder.RegisterModule<LogInjectionModule>(); containerBuilder.RegisterModule<LogInjectionModule>();
} }

View File

@ -40,7 +40,8 @@ namespace NzbDrone.Core.Tv
public class EpisodeService : IEpisodeService, public class EpisodeService : IEpisodeService,
IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeFileDeletedEvent>, IHandle<EpisodeFileDeletedEvent>,
IHandleAsync<SeriesDeletedEvent> IHandleAsync<SeriesDeletedEvent>,
IHandleAsync<SeriesAddedEvent>
{ {
private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private static readonly Logger logger = LogManager.GetCurrentClassLogger();
@ -399,5 +400,10 @@ namespace NzbDrone.Core.Tv
UpdateEpisode(episode); UpdateEpisode(episode);
} }
} }
public void HandleAsync(SeriesAddedEvent message)
{
RefreshEpisodeInfo(message.Series);
}
} }
} }

View File

@ -80,7 +80,9 @@ namespace NzbDrone.Core.Tv
try try
{ {
if (series.TvRageId == 0) if (series.TvRageId == 0)
{
series = _tvRageMappingProvider.FindMatchingTvRageSeries(series); series = _tvRageMappingProvider.FindMatchingTvRageSeries(series);
}
} }
catch (Exception ex) catch (Exception ex)