From a83e07d785f636d6ee1de3da61c43b16f0dffbab Mon Sep 17 00:00:00 2001 From: Lombiq Date: Fri, 28 Feb 2014 20:22:16 +0100 Subject: [PATCH] #20525: LocalizationModule and LoggingModule don't fail anymore if you swap the implementation of a dependency mid-way with some Autofac-fu Work Item: 20525 --- src/Orchard/Localization/LocalizationModule.cs | 4 ++++ src/Orchard/Logging/LoggingModule.cs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/Orchard/Localization/LocalizationModule.cs b/src/Orchard/Localization/LocalizationModule.cs index 7939aab0b..11f1ae61a 100644 --- a/src/Orchard/Localization/LocalizationModule.cs +++ b/src/Orchard/Localization/LocalizationModule.cs @@ -25,6 +25,10 @@ namespace Orchard.Localization { var scope = registration.Activator.LimitType.FullName; registration.Activated += (sender, e) => { + if (e.Instance.GetType().FullName != scope) { + return; + } + var localizer = _localizerCache.GetOrAdd(scope, key => LocalizationUtilities.Resolve(e.Context, scope)); userProperty.SetValue(e.Instance, localizer, null); }; diff --git a/src/Orchard/Logging/LoggingModule.cs b/src/Orchard/Logging/LoggingModule.cs index b658d7073..49fb93568 100644 --- a/src/Orchard/Logging/LoggingModule.cs +++ b/src/Orchard/Logging/LoggingModule.cs @@ -62,6 +62,9 @@ namespace Orchard.Logging { yield return (ctx, instance) => { string component = componentType.ToString(); + if (component != instance.GetType().ToString()) { + return; + } var logger = _loggerCache.GetOrAdd(component, key => ctx.Resolve(new TypedParameter(typeof(Type), componentType))); propertyInfo.SetValue(instance, logger, null); };