mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#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:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user