Пример #1
0
        public static async Task <bool> DispatchActionAsync <TTarget, TIn, TContext>(this TTarget target, TIn input, TContext context)
        {
            var task = FuncContextDispatcher <TTarget, TIn, TContext, Task> .Dispatch(target, input, context);

            if (task == null)
            {
                return(false);
            }

            await task;

            return(true);
        }
Пример #2
0
        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> > .Dispatch(target, input, context);

            return(result ?? Task.FromResult(fallback));
        }
Пример #3
0
        public static TOut DispatchFunc <TTarget, TIn, TContext, TOut>(this TTarget target, TIn input, TContext context, TOut fallback)
        {
            var result = FuncContextDispatcher <TTarget, TIn, TContext, TOut> .Dispatch(target, input, context);

            return(Equals(result, default(TOut)) ? fallback : result);
        }