예제 #1
0
        public override bool ContinuePipeLineEntry <TA, TB>(
            IValueAndSupplement <TA, TB> pipeInput,
            out PipeBase <TA, TB> wrapInputIntoPipeBase,
            out IPipeOption pipeOption)
        {
            if (pipeInput == null)
            {
                pipeOption            = new PipeOption(null, null);
                wrapInputIntoPipeBase = new None <TA, TB>(pipeOption);
                return(false);
            }
            pipeOption = (IPipeOption)pipeInput;

            if (pipeInput.GetType() == typeof(Option <TA, TB>))
            {
                wrapInputIntoPipeBase = new None <TA, TB>(pipeOption);
                return(false);
            }
            if (pipeInput.GetType() == typeof(SomeException <TA, TB>))
            {
                wrapInputIntoPipeBase = new SomeException <TA, TB>(((SomeException <TA, TB>)pipeInput).ExceptionVal, pipeOption);
                return(false);
            }
            if (pipeInput.GetType() == typeof(Validation <TA, TB>))
            {
                wrapInputIntoPipeBase = new Validation <TA, TB>(new ValueAndSupplement <TA, TB>(pipeInput.Val, pipeInput.SupplementVal), pipeOption, ((Validation <TV, TS>)pipeInput).ValidationRet);
                return(false);
            }

            wrapInputIntoPipeBase = new Some <TA, TB>(new ValueAndSupplement <TA, TB>(pipeInput.Val, pipeInput.SupplementVal), pipeOption);
            return(true);
        }
예제 #2
0
        public override bool ContinuePipeLineEntry <TA, TB, TC, TD>(
            IValueAndSupplement <TA, TB> pipeInput,
            out PipeBase <TC, TD> wrapInputIntoPipeBaseWhenBreak,
            out IPipeOption pipeOption)
        {
            //Determine pipeBaseWhenContinue
            if (pipeInput == null)
            {
                pipeOption = new PipeOption(null, null);
            }
            else
            {
                pipeOption = (IPipeOption)pipeInput;
            }


            //Determine pipeBaseWhenBreak
            if (pipeInput.GetType() == typeof(Option <TA, TB>))
            {
                wrapInputIntoPipeBaseWhenBreak = new None <TC, TD>(pipeOption);
                return(false);
            }
            if (pipeInput.GetType() == typeof(SomeException <TA, TB>))
            {
                wrapInputIntoPipeBaseWhenBreak = new SomeException <TC, TD>(((SomeException <TA, TB>)pipeInput).ExceptionVal, pipeOption);
                return(false);
            }

            if (pipeInput.GetType() == typeof(Validation <TA, TB>))
            {
                wrapInputIntoPipeBaseWhenBreak = new Validation <TC, TD>(new ValueAndSupplement <TC, TD>(default(TC), default(TD)), pipeOption, ((Validation <TC, TD>)pipeInput).ValidationRet);
                return(false);
            }

            //Because of the out signature we need to instantiate a pipeBaseWhenBreak, but it will be ignored because we return true, meaning don't break
            wrapInputIntoPipeBaseWhenBreak = new Some <TC, TD>(new ValueAndSupplement <TC, TD>(default(TC), default(TD)), pipeOption);
            return(true);
        }