示例#1
0
        public static async Task <bool> DispatchActionAsync <TTarget, TIn>(this TTarget target, TIn input)
        {
            var task = FuncDispatcher <TTarget, TIn, Task> .On(target, input);

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

            await task;

            return(true);
        }
示例#2
0
        public static Task <TOut> DispatchFuncAsync <TTarget, TIn, TOut>(this TTarget target, TIn input, TOut fallback)
        {
            var result = FuncDispatcher <TTarget, TIn, Task <TOut> > .On(target, input);

            return(result ?? Task.FromResult(fallback));
        }
示例#3
0
        public static TOut DispatchFunc <TTarget, TIn, TOut>(this TTarget target, TIn input, TOut fallback)
        {
            var result = FuncDispatcher <TTarget, TIn, TOut> .On(target, input);

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