diff --git a/dotnet/samples/Demos/ProcessWithDapr/Controllers/ProcessController.cs b/dotnet/samples/Demos/ProcessWithDapr/Controllers/ProcessController.cs index 21bf44ae717c..efbd990cb692 100644 --- a/dotnet/samples/Demos/ProcessWithDapr/Controllers/ProcessController.cs +++ b/dotnet/samples/Demos/ProcessWithDapr/Controllers/ProcessController.cs @@ -120,7 +120,7 @@ public async ValueTask DoItAsync(KernelProcessStepContext context) { Console.WriteLine("##### AStep ran."); await Task.Delay(TimeSpan.FromSeconds(1)); - await context.EmitEventAsync(new() { Id = CommonEvents.AStepDone, Data = "I did A" }); + await context.EmitEventAsync(CommonEvents.AStepDone, "I did A"); } } diff --git a/dotnet/src/Experimental/Process.Abstractions/KernelProcessStepContext.cs b/dotnet/src/Experimental/Process.Abstractions/KernelProcessStepContext.cs index b7a3da7bfb6a..bf4aba1321db 100644 --- a/dotnet/src/Experimental/Process.Abstractions/KernelProcessStepContext.cs +++ b/dotnet/src/Experimental/Process.Abstractions/KernelProcessStepContext.cs @@ -29,4 +29,25 @@ public ValueTask EmitEventAsync(KernelProcessEvent processEvent) { return this._stepMessageChannel.EmitEventAsync(processEvent); } + + /// + /// Emit an event from the current step with a simplified method signature. + /// + /// + /// + /// + /// + public ValueTask EmitEventAsync( + string eventId, + object? data = null, + KernelProcessEventVisibility visibility = KernelProcessEventVisibility.Internal) + { + return this._stepMessageChannel.EmitEventAsync( + new KernelProcessEvent + { + Id = eventId, + Data = data, + Visibility = visibility + }); + } } diff --git a/dotnet/src/IntegrationTests/Processes/ProcessCycleTests.cs b/dotnet/src/IntegrationTests/Processes/ProcessCycleTests.cs index bb01f01f561b..033359b8895d 100644 --- a/dotnet/src/IntegrationTests/Processes/ProcessCycleTests.cs +++ b/dotnet/src/IntegrationTests/Processes/ProcessCycleTests.cs @@ -98,7 +98,7 @@ public static class Functions public async ValueTask PrintWelcomeMessageAsync(KernelProcessStepContext context) { await context.EmitEventAsync(new() { Id = CommonEvents.StartARequested, Data = "Get Going A" }); - await context.EmitEventAsync(new() { Id = CommonEvents.StartBRequested, Data = "Get Going B" }); + await context.EmitEventAsync(CommonEvents.StartBRequested, "Get Going B", KernelProcessEventVisibility.Internal); } } @@ -124,7 +124,7 @@ private sealed class BStep : KernelProcessStep public async ValueTask DoItAsync(KernelProcessStepContext context) { await Task.Delay(TimeSpan.FromSeconds(2)); - await context.EmitEventAsync(new() { Id = CommonEvents.BStepDone, Data = "I did B" }); + await context.EmitEventAsync(CommonEvents.BStepDone, "I did B"); } }