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;
private readonly ILogger logger;
///
public FlowStarter(ITapetiConfig config, ILogger logger)
{
this.config = config;
this.logger = logger;
}
///
public Task Start(Expression>> methodSelector) where TController : class
{
return CallControllerMethod(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), new object[] { });
}
///
public Task Start(Expression>>> methodSelector) where TController : class
{
return CallControllerMethod(GetExpressionMethod(methodSelector), value => (Task)value, new object[] {});
}
///
public Task Start(Expression>> methodSelector, TParameter parameter) where TController : class
{
return CallControllerMethod(GetExpressionMethod(methodSelector), value => Task.FromResult((IYieldPoint)value), new object[] {parameter});
}
///
public Task Start(Expression>>> methodSelector, TParameter parameter) where TController : class
{
return CallControllerMethod(GetExpressionMethod(methodSelector), value => (Task)value, new object[] {parameter});
}
private async Task CallControllerMethod(MethodBase method, Func