From 12140e9a7cb8cbea6b522e25e1dde6ccec9bac22 Mon Sep 17 00:00:00 2001 From: Alistair Evans Date: Wed, 20 May 2020 16:04:13 +0100 Subject: [PATCH] Integrate changes from v6 branch --- ...nBuilder{TLimit,TActivatorData,TRegistrationStyle}.cs | 6 +++--- src/Autofac/Core/ActivatedEventArgs.cs | 4 ++-- src/Autofac/Core/ActivatingEventArgs.cs | 9 ++++++++- src/Autofac/Core/PreparingEventArgs.cs | 6 +++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Autofac/Builder/RegistrationBuilder{TLimit,TActivatorData,TRegistrationStyle}.cs b/src/Autofac/Builder/RegistrationBuilder{TLimit,TActivatorData,TRegistrationStyle}.cs index ee11c3205..49312044e 100644 --- a/src/Autofac/Builder/RegistrationBuilder{TLimit,TActivatorData,TRegistrationStyle}.cs +++ b/src/Autofac/Builder/RegistrationBuilder{TLimit,TActivatorData,TRegistrationStyle}.cs @@ -386,7 +386,7 @@ public IRegistrationBuilder OnPrepar ResolvePipeline.Use(nameof(OnPreparing), PipelinePhase.ParameterSelection, (ctxt, next) => { - var args = new PreparingEventArgs(ctxt, ctxt.Registration, ctxt.Parameters); + var args = new PreparingEventArgs(ctxt, ctxt.Service, ctxt.Registration, ctxt.Parameters); handler(args); @@ -414,7 +414,7 @@ public IRegistrationBuilder OnActiva { next(ctxt); - var args = new ActivatingEventArgs(ctxt, ctxt.Registration, ctxt.Parameters, (TLimit)ctxt.Instance!); + var args = new ActivatingEventArgs(ctxt, ctxt.Service, ctxt.Registration, ctxt.Parameters, (TLimit)ctxt.Instance!); handler(args); ctxt.Instance = args.Instance; @@ -452,7 +452,7 @@ public IRegistrationBuilder OnActiva ctxt.RequestCompleting += (sender, evArgs) => { var ctxt = evArgs.RequestContext; - var args = new ActivatedEventArgs(ctxt, ctxt.Registration, ctxt.Parameters, newInstance); + var args = new ActivatedEventArgs(ctxt, ctxt.Service, ctxt.Registration, ctxt.Parameters, newInstance); handler(args); }; diff --git a/src/Autofac/Core/ActivatedEventArgs.cs b/src/Autofac/Core/ActivatedEventArgs.cs index 2d1ea3215..6dd4da4c0 100644 --- a/src/Autofac/Core/ActivatedEventArgs.cs +++ b/src/Autofac/Core/ActivatedEventArgs.cs @@ -43,10 +43,10 @@ public class ActivatedEventArgs : EventArgs, IActivatedEventArgs /// The service being resolved. public ActivatedEventArgs( IComponentContext context, + Service service, IComponentRegistration component, IEnumerable parameters, - T instance, - Service service) + T instance) { if (context == null) throw new ArgumentNullException(nameof(context)); if (component == null) throw new ArgumentNullException(nameof(component)); diff --git a/src/Autofac/Core/ActivatingEventArgs.cs b/src/Autofac/Core/ActivatingEventArgs.cs index 2b106b12a..bdd3c20a6 100644 --- a/src/Autofac/Core/ActivatingEventArgs.cs +++ b/src/Autofac/Core/ActivatingEventArgs.cs @@ -41,22 +41,29 @@ public class ActivatingEventArgs : EventArgs, IActivatingEventArgs /// Initializes a new instance of the class. /// /// The context. + /// The service. /// The component. /// The parameters. /// The instance. - public ActivatingEventArgs(IComponentContext context, IComponentRegistration component, IEnumerable parameters, T instance) + public ActivatingEventArgs(IComponentContext context, Service service, IComponentRegistration component, IEnumerable parameters, T instance) { if (context == null) throw new ArgumentNullException(nameof(context)); if (component == null) throw new ArgumentNullException(nameof(component)); if (parameters == null) throw new ArgumentNullException(nameof(parameters)); if (instance == null) throw new ArgumentNullException(nameof(instance)); + Service = service; Context = context; Component = component; Parameters = parameters; _instance = instance; } + /// + /// Gets the service being resolved. + /// + public Service Service { get; } + /// /// Gets the context in which the activation occurred. /// diff --git a/src/Autofac/Core/PreparingEventArgs.cs b/src/Autofac/Core/PreparingEventArgs.cs index 419929989..768ffd429 100644 --- a/src/Autofac/Core/PreparingEventArgs.cs +++ b/src/Autofac/Core/PreparingEventArgs.cs @@ -39,20 +39,20 @@ public class PreparingEventArgs : EventArgs /// /// Initializes a new instance of the class. /// + /// The service being resolved. /// The context. /// The component. /// The parameters. - /// The service being resolved. - public PreparingEventArgs(IComponentContext context, IComponentRegistration component, IEnumerable parameters, Service service) + public PreparingEventArgs(IComponentContext context, Service service, IComponentRegistration component, IEnumerable parameters) { if (context == null) throw new ArgumentNullException(nameof(context)); if (component == null) throw new ArgumentNullException(nameof(component)); if (parameters == null) throw new ArgumentNullException(nameof(parameters)); Context = context; + Service = service; Component = component; _parameters = parameters; - Service = service; } ///