From fd12e5c6202d55cd6fc99542db07ec35defb3bcf Mon Sep 17 00:00:00 2001 From: Damian Edwards Date: Mon, 12 May 2025 17:16:36 -0700 Subject: [PATCH] API review: Add Services property to ResourceEndpointsAllocatedEvent --- Aspire.sln | 2 +- .../ApplicationModel/ResourceEndpointsAllocatedEvent.cs | 7 ++++++- src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Aspire.sln b/Aspire.sln index bfcf8b6c2f0..c6f65e7fdff 100644 --- a/Aspire.sln +++ b/Aspire.sln @@ -3928,7 +3928,7 @@ Global {A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|x64.Build.0 = Release|Any CPU {A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|x86.ActiveCfg = Release|Any CPU {A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|x86.Build.0 = Release|Any CPU - {6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|Any CPU.Build.0 = Debug|Any CPU {6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|x64.ActiveCfg = Debug|Any CPU {6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|x64.Build.0 = Debug|Any CPU diff --git a/src/Aspire.Hosting/ApplicationModel/ResourceEndpointsAllocatedEvent.cs b/src/Aspire.Hosting/ApplicationModel/ResourceEndpointsAllocatedEvent.cs index 53d2d4162a0..f5093c91bac 100644 --- a/src/Aspire.Hosting/ApplicationModel/ResourceEndpointsAllocatedEvent.cs +++ b/src/Aspire.Hosting/ApplicationModel/ResourceEndpointsAllocatedEvent.cs @@ -11,8 +11,13 @@ namespace Aspire.Hosting.ApplicationModel; /// /// Any resources that customize their URLs via a will have their callbacks invoked during this event. /// -public class ResourceEndpointsAllocatedEvent(IResource resource) : IDistributedApplicationEvent +public class ResourceEndpointsAllocatedEvent(IResource resource, IServiceProvider services) : IDistributedApplicationEvent { /// public IResource Resource { get; } = resource; + + /// + /// The instance. + /// + public IServiceProvider Services { get; } = services; } diff --git a/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs b/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs index eb8015cb214..6b6c1ac1389 100644 --- a/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs +++ b/src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs @@ -105,7 +105,7 @@ private async Task OnEndpointsAllocated(OnEndpointsAllocatedContext context) // Fire the endpoints allocated event for all resources. foreach (var resource in _model.Resources) { - await _eventing.PublishAsync(new ResourceEndpointsAllocatedEvent(resource), EventDispatchBehavior.NonBlockingConcurrent, context.CancellationToken).ConfigureAwait(false); + await _eventing.PublishAsync(new ResourceEndpointsAllocatedEvent(resource, _serviceProvider), EventDispatchBehavior.NonBlockingConcurrent, context.CancellationToken).ConfigureAwait(false); } }