1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed IInitializable registration

I tried to make it all happen in the same method as AutoRegisterImplementations, but it caused issues with BasicRepo.
This commit is contained in:
Mark McDowall 2013-04-05 18:03:14 -07:00
parent 28d4010c5c
commit 9ae21cf7a1
4 changed files with 22 additions and 7 deletions

View File

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

View File

@ -45,7 +45,11 @@ public static void Map()
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");

View File

@ -21,7 +21,6 @@ public List<Series> SearchForNewSeries(string title)
return response.Data.Select(MapSeries).ToList();
}
public Series GetSeriesInfo(int tvDbSeriesId)
{
var client = BuildClient("show", "summary");
@ -40,7 +39,6 @@ public IList<Episode> GetEpisodeInfo(int tvDbSeriesId)
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));

View File

@ -13,6 +13,7 @@
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 @@ static ContainerBuilder()
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 @@ private static void AutoRegisterImplementations<TContract>(this TinyIoCContainer
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();
}
}
}