public static async Task <bool> DispatchActionAsync <TTarget, TIn, TContext>(this TTarget target, TIn input, TContext context) { var task = FuncContextDispatcher <TTarget, TIn, TContext, Task> .On(target, input, context); if (task == null) { return(false); } await task; return(true); }
public static Task <TOut> DispatchFuncAsync <TTarget, TIn, TContext, TOut>(this TTarget target, TIn input, TContext context, TOut fallback) { var result = FuncContextDispatcher <TTarget, TIn, TContext, Task <TOut> > .On(target, input, context); return(result ?? Task.FromResult(fallback)); }
public static TOut DispatchFunc <TTarget, TIn, TContext, TOut>(this TTarget target, TIn input, TContext context, TOut fallback) { var result = FuncContextDispatcher <TTarget, TIn, TContext, TOut> .On(target, input, context); return(Equals(result, default(TOut)) ? fallback : result); }