Esempio n. 1
0
 public override ICompletes <TResult> With(TResult outcome)
 {
     HasException.Set(false);
     HasFailedValue.Set(false);
     base.With(outcome);
     ReadyToExectue.Set(false);
     RepeatInternal();
     return(this);
 }
Esempio n. 2
0
        internal override void InnerInvoke(BasicCompletes completedCompletes)
        {
            if (HasException.Get())
            {
                return;
            }

            if (Action is Action invokableAction)
            {
                invokableAction();
                return;
            }

            if (Action is Action <TResult> invokableActionInput)
            {
                if (completedCompletes is AndThenContinuation <TResult, TResult> andThenContinuation)
                {
                    invokableActionInput(andThenContinuation.FailedOutcomeValue.Get());
                    OutcomeKnown.Set();
                    return;
                }
            }

            if (Action is Func <ICompletes <TAntecedentResult>, TResult> funcCompletes)
            {
                OutcomeValue.Set(funcCompletes(antecedent));
                OutcomeKnown.Set();
                return;
            }

            if (Action is Func <TAntecedentResult, TResult> function)
            {
                if (completedCompletes is AndThenContinuation <TResult, TAntecedentResult> andThenContinuation)
                {
                    OutcomeValue.Set(function(andThenContinuation.FailedOutcomeValue.Get()));
                    OutcomeKnown.Set();
                    return;
                }

                if (completedCompletes is BasicCompletes <TAntecedentResult> otherwiseContinuation)
                {
                    OutcomeValue.Set(function(otherwiseContinuation.FailedOutcomeValue.Get()));
                    OutcomeKnown.Set();
                    return;
                }
            }

            base.InnerInvoke(completedCompletes);

            throw new InvalidCastException("Cannot run 'Otherwise' function. Make sure that expecting type is the same as failedOutcomeValue type");
        }