Skip to content

Instantly share code, notes, and snippets.

@mamidenn
Created August 13, 2023 08:08
Show Gist options
  • Save mamidenn/9bb4d3c4d995fe8c1c4ce465437a7e65 to your computer and use it in GitHub Desktop.
Save mamidenn/9bb4d3c4d995fe8c1c4ce465437a7e65 to your computer and use it in GitHub Desktop.
Skipping Middleware for steps like `If`, `While`, etc. prevents unnecessary operations
public class Middleware : IWorkflowStepMiddleware
{
public async Task<ExecutionResult> HandleAsync(IStepExecutionContext context, IStepBody body, WorkflowStepDelegate next)
{
if (body is ContainerStepBody) return await next();
Debug.WriteLine($"Start: {context.Step.Name ?? body.GetType().Name}");
var result = await next();
Debug.WriteLine($"End: {context.Step.Name ?? body.GetType().Name}");
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment