using System;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using Tapeti.Config;
namespace Tapeti.Flow.Default
{
///
///
/// Default implementation for IFlowStarter.
///
internal class FlowStarter : IFlowStarter
{
private readonly ITapetiConfig config;
///
public FlowStarter(ITapetiConfig config)
{
this.config = config;
}
///
public async Task Start(Expression>> methodSelector) where TController : class
{
await CallControllerMethod(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), new object[] { });
}
///
public async Task Start(Expression>>> methodSelector) where TController : class
{
await CallControllerMethod(GetExpressionMethod(methodSelector), value => (Task)value, new object[] {});
}
///
public async Task Start(Expression>> methodSelector, TParameter parameter) where TController : class
{
await CallControllerMethod(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), new object[] {parameter});
}
///
public async Task Start(Expression>>> methodSelector, TParameter parameter) where TController : class
{
await CallControllerMethod(GetExpressionMethod(methodSelector), value => (Task)value, new object[] {parameter});
}
private async Task CallControllerMethod(MethodInfo method, Func