Files

22 lines
713 B
C#
Raw Permalink Normal View History

2020-07-19 13:04:31 +02:00
using System;
using System.Threading.Tasks;
namespace WotBlitzStatisticsPro.Logic.Pipeline
{
public class OperationMediator<TContext>: IOperation<TContext>
{
private readonly IOperation<TContext> _current;
2020-12-27 12:39:25 +01:00
private readonly IOperation<TContext>? _next;
2020-07-19 13:04:31 +02:00
2020-12-27 12:39:25 +01:00
public OperationMediator(IOperation<TContext> current, IOperation<TContext>? next)
2020-07-19 13:04:31 +02:00
{
_current = current ?? throw new ArgumentNullException(nameof(current));
_next = next;
}
2020-12-27 12:39:25 +01:00
public Task Invoke(TContext context, Func<TContext, Task>? next)
2020-07-19 13:04:31 +02:00
{
return _current.Invoke(context, c => _next == null ? Task.CompletedTask : _next.Invoke(c, null));
}
}
}