Exemple #1
0
        TResult IUnionFuncPatternMatcherAfterElse <TResult> .Result()
        {
            var possibleResult = _union.Case == Variant.Case1
                ? _case1FunctionSelector.DetermineResult(_union.Case1)
                : _case2FunctionSelector.DetermineResult(_union.Case2);

            return(possibleResult.HasValue ? possibleResult.Value : _elseAction(_success));
        }
Exemple #2
0
        TResult IUnionFuncPatternMatcherAfterElse <TResult> .Result()
        {
            var possibleResult = _valueOrError.HasValue
                ? _valueFunctionSelector.DetermineResult(_valueOrError.Value)
                : _errorFunctionSelector.DetermineResult(_valueOrError.Error);

            return(possibleResult.HasValue ? possibleResult.Value : _elseAction(_valueOrError));
        }
Exemple #3
0
        private Option <TResult> DetermineResult(IUnion <T1, T2, T3, T4> union)
        {
            switch (union.Case)
            {
            case Case1: return(_case1Selector.DetermineResult(union.Case1));

            case Case2: return(_case2Selector.DetermineResult(union.Case2));

            case Case3: return(_case3Selector.DetermineResult(union.Case3));

            default: return(_case4Selector.DetermineResult(union.Case4));
            }
        }