#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
This commit is contained in:
Lombiq
2014-02-28 20:22:16 +01:00
committed by Zoltán Lehóczky
parent 53a0f91747
commit a83e07d785
2 changed files with 7 additions and 0 deletions

View File

@@ -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);
};

View File

@@ -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<ILogger>(new TypedParameter(typeof(Type), componentType)));
propertyInfo.SetValue(instance, logger, null);
};