1
0
mirror of synced 2024-11-16 14:53:50 +00:00
Tapeti/Tapeti.Flow/Default/FlowMessageMiddleware.cs

25 lines
694 B
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
using Tapeti.Config;
namespace Tapeti.Flow.Default
{
public class FlowMessageMiddleware : IMessageMiddleware
{
public async Task Handle(IMessageContext context, Func<Task> next)
{
var flowContext = (FlowContext)context.Items[ContextItems.FlowContext];
if (flowContext != null)
{
Newtonsoft.Json.JsonConvert.PopulateObject(flowContext.FlowState.Data, context.Controller);
await next();
flowContext.FlowState.Continuations.Remove(flowContext.ContinuationID);
}
else
await next();
}
}
}