Fixed IInitializable registration

I tried to make it all happen in the same method as AutoRegisterImplementations, but it caused issues with BasicRepo.
pull/6/head
Mark McDowall 12 years ago
parent 28d4010c5c
commit 9ae21cf7a1

@ -44,7 +44,7 @@ namespace NzbDrone.Api
private void KickoffInitilizables(TinyIoCContainer container)
{
var initilizables = container.Resolve<IEnumerable<IInitializable>>();
var initilizables = container.ResolveAll<IInitializable>();
foreach (var initializable in initilizables)
{

@ -38,14 +38,18 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity<SceneMapping>().RegisterModel("SceneMappings");
Mapper.Entity<History.History>().RegisterModel("History")
.HasOne(h => h.Episode, h => h.EpisodeId);
.HasOne(h => h.Episode, h => h.EpisodeId);
Mapper.Entity<Series>().RegisterModel("Series");
Mapper.Entity<Season>().RegisterModel("Seasons");
Mapper.Entity<Episode>().RegisterModel("Episodes");
Mapper.Entity<EpisodeFile>().RegisterModel("EpisodeFiles");
Mapper.Entity<QualityProfile>().RegisterModel("QualityProfiles").For(q => q.DbAllowed).SetColumnName("Allowed").Ignore(q => q.Allowed);
Mapper.Entity<QualityProfile>().RegisterModel("QualityProfiles")
.For(q => q.DbAllowed).SetColumnName("Allowed")
.Ignore(q => q.Allowed);
Mapper.Entity<QualitySize>().RegisterModel("QualitySizes");
Mapper.Entity<Log>().RegisterModel("Logs");

@ -21,7 +21,6 @@ namespace NzbDrone.Core.MetadataSource
return response.Data.Select(MapSeries).ToList();
}
public Series GetSeriesInfo(int tvDbSeriesId)
{
var client = BuildClient("show", "summary");
@ -40,7 +39,6 @@ namespace NzbDrone.Core.MetadataSource
return response.Data.seasons.SelectMany(c => c.episodes).Select(MapEpisode).ToList();
}
private static IRestClient BuildClient(string resource, string method)
{
return new RestClient(string.Format("http://api.trakt.tv/{0}/{1}.json/6fc98f83c6a02decd17eb7e13d00e89c", resource, method));

@ -13,6 +13,7 @@ using NzbDrone.Core.Datastore.Migration.Framework;
using NzbDrone.Core.ExternalNotification;
using NzbDrone.Core.IndexerSearch;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Lifecycle;
using NzbDrone.Core.RootFolders;
using TinyIoC;
@ -36,6 +37,7 @@ namespace NzbDrone
container.AutoRegisterImplementations<IndexerBase>();
container.AutoRegisterImplementations<IndexerSearchBase>();
container.AutoRegisterImplementations<ExternalNotificationBase>();
container.AutoRegisterMultipleImplementations<IInitializable>();
container.Register<IEventAggregator, EventAggregator>().AsSingleton();
container.Register<INancyBootstrapper, TinyNancyBootstrapper>().AsSingleton();
@ -88,13 +90,24 @@ namespace NzbDrone
private static void AutoRegisterImplementations(this TinyIoCContainer container, Type contractType)
{
var implementations = contractType.Assembly.GetImplementations(contractType);
var implementations = contractType.Assembly.GetImplementations(contractType).ToList();
foreach (var implementation in implementations)
foreach(var implementation in implementations)
{
logger.Trace("Registering {0} as {1}", implementation.Name, contractType.Name);
container.Register(contractType, implementation).AsMultiInstance();
}
}
private static void AutoRegisterMultipleImplementations<TContract>(this TinyIoCContainer container)
{
container.AutoRegisterMultipleImplementations(typeof(TContract));
}
private static void AutoRegisterMultipleImplementations(this TinyIoCContainer container, Type contractType)
{
var implementations = contractType.Assembly.GetImplementations(contractType);
container.RegisterMultiple(contractType, implementations).AsMultiInstance();
}
}
}
Loading…
Cancel
Save