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); }
public override bool ContinuePipeLineEntry <TB, TA>( IValueAndSupplement <TA, TB> pipeInput, out PipeBase <TB, TA> wrapInputIntoPipeBase, out IPipeOption pipeOption) { if (pipeInput == null) { pipeOption = PipeOption.PipeOptionNone; wrapInputIntoPipeBase = new Validator <TB, TA>(pipeOption, ValidationResult.None, null); return(false); } if (pipeInput.GetType() != typeof(Validator <TA, TB>)) { pipeOption = PipeOption.PipeOptionNone; wrapInputIntoPipeBase = new Validator <TB, TA>(new InvalidCastException(), pipeOption, null); return(false); } pipeOption = (IPipeOption)pipeInput; var validatorType = ((Validator <TA, TB>)pipeInput).ValidatorType; if (validatorType == ValidationResult.Exception) { wrapInputIntoPipeBase = new Validator <TB, TA>(((Validator <TA, TB>)pipeInput).ExceptionVal, pipeOption, null); return(false); } wrapInputIntoPipeBase = new Validator <TB, TA>(new ValueAndSupplement <TB, TA>(pipeInput.SupplementVal, pipeInput.Val), pipeOption, ExtractMessages(pipeInput.Val, pipeInput.SupplementVal)); return(true); }
internal Validator(Exception ex, IPipeOption pipeOption, List <string> messages) { ConditionMet = pipeOption.ConditionIsMet; ExtensionInterfaces = pipeOption.Extensions; ValidatorType = ValidationResult.Exception; this.ex = ex; }
public abstract bool ContinuePipeLineEntry <TA, TB, TC, TD>( IValueAndSupplement <TA, TB> pipeInput, out PipeBase <TC, TD> wrapInputIntoPipeBaseWhenBreak, out IPipeOption pipeOption) where TA : new() where TB : new() where TC : new() where TD : new();
internal Validator(IValueAndSupplement <TV, TS> val, IPipeOption pipeOption, List <string> messages) { ConditionMet = pipeOption.ConditionIsMet; ExtensionInterfaces = pipeOption.Extensions; ValidatorType = val == null ? ValidationResult.None : ValidationResult.Some; var extractedMessages = messages ?? new List <string>(); if (extractedMessages.Count > 0) { this.ValidatorType = ValidationResult.SomeInvalid; } if (val != null) { GetValue = val.Val; GetSupplement = val.SupplementVal; } }
protected void ExecuteExtensions( IPipeOption pipeOption, object val) { if (val == null) { return; } if (pipeOption?.Extensions != null) { foreach (var ext in pipeOption.Extensions) { if (val is IExpose) { ext.PostProcess(val as IExpose); } } ; } }
public override bool ContinuePipeLineEntry <TA, TB, TC, TD>( IValueAndSupplement <TA, TB> pipeInput, out PipeBase <TC, TD> wrapInputIntoPipeBaseWhenBreak, out IPipeOption pipeOption) { if (pipeInput == null) { pipeOption = PipeOption.PipeOptionNone; wrapInputIntoPipeBaseWhenBreak = new Validator <TC, TD>(pipeOption, ValidationResult.None, null); return(false); } if (pipeInput.GetType() != typeof(Validator <TA, TB>)) { pipeOption = PipeOption.PipeOptionNone; wrapInputIntoPipeBaseWhenBreak = new Validator <TC, TD>(new InvalidCastException(), pipeOption, null); return(false); } pipeOption = (IPipeOption)pipeInput; var validatorType = ((Validator <TA, TB>)pipeInput).ValidatorType; if (validatorType == ValidationResult.None) { wrapInputIntoPipeBaseWhenBreak = new Validator <TC, TD>(pipeOption, ValidationResult.None, null); return(false); } if (validatorType == ValidationResult.Exception) { wrapInputIntoPipeBaseWhenBreak = new Validator <TC, TD>(((Validator <TA, TB>)pipeInput).ExceptionVal, pipeOption, null); return(false); } //Because of the out signature we need to instantiate a wrapInputIntoPipeBase, but it will be ignored because we return true, meaning don't break wrapInputIntoPipeBaseWhenBreak = new Validator <TC, TD>(new ValueAndSupplement <TC, TD>(default(TC), default(TD)), pipeOption, new List <string>()); return(true); }
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); }
public override PipeBase <TV, TS> CreateNone(IPipeOption pipeOption) { return(new Validator <TV, TS>(pipeOption, ValidationResult.None, null)); }
public override PipeBase <TA, TB> CreateException <TA, TB>(Exception ex, IPipeOption pipeOption) { return(new Validator <TA, TB>(ex, pipeOption, null)); }
public override PipeBase <TA, TB> WrapPipeLineResult <TA, TB>(TA value, TB supplementedValue, IPipeOption pipeOption) { if (value == null && supplementedValue == null) { return(new SomeException <TA, TB>(new InvalidOperationException("Null values for value and supplemented value are not allowed!"), pipeOption)); } if (supplementedValue == null) { return(new SomeException <TA, TB>(new InvalidOperationException("Null values for supplemented value is not allowed!"), pipeOption)); } try { ExecuteExtensions(pipeOption, value); ExecuteExtensions(pipeOption, supplementedValue); } catch (Exception ex) { return(new SomeException <TA, TB>(ex, pipeOption)); } return(new Some <TA, TB>(new ValueAndSupplement <TA, TB>(value, supplementedValue), pipeOption)); }
public override PipeBase <TV, TS> CreateSome(IValueAndSupplement <TV, TS> val, IPipeOption pipeOption) { return(new Some <TV, TS>(val, pipeOption)); }
public override PipeBase <TV, TS> CreateNone(IPipeOption pipeOption) { return(new None <TV, TS>(pipeOption)); }
public abstract PipeBase <TV, TS> CreateSome( IValueAndSupplement <TV, TS> val, IPipeOption pipeOption);
public override PipeBase <TA, TB> WrapPipeLineResult <TA, TB>(TA value, TB supplementedValue, IPipeOption pipeOption) { var msgs = new List <string>(); if (value == null && supplementedValue == null) { return(new Validator <TA, TB>(new InvalidOperationException("Null values for value and supplemented value are not allowed!"), pipeOption, new List <string>())); } if (supplementedValue == null) { return(new Validator <TA, TB>(new InvalidOperationException("Null values for supplemented value is not allowed!"), pipeOption, new List <string>())); } try { ExecuteExtensions(pipeOption, value); ExecuteExtensions(pipeOption, supplementedValue); msgs = ExtractMessages(value, supplementedValue); } catch (Exception exExtensions) { return(new Validator <TA, TB>(exExtensions, pipeOption, ExtractMessages(value, supplementedValue))); } return(new Validator <TA, TB>(new ValueAndSupplement <TA, TB>(value, supplementedValue), pipeOption, msgs)); }
public Validation(IValueAndSupplement <TV, TS> val, IPipeOption pipeOption, ValidationResult validationResult) : base(pipeOption) { SomeValAndSupplement = val; ValidationRet = validationResult; }
public abstract PipeBase <TV, TS> CreateValidation( IValueAndSupplement <TV, TS> val, IPipeOption pipeOption, ValidationResult result);
public Some(IValueAndSupplement <TV, TS> val, IPipeOption pipeOption) : base(pipeOption) { SomeValAndSupplement = val; }
internal Option(IPipeOption pipeOption) { ConditionMet = pipeOption?.ConditionIsMet; ExtensionInterfaces = pipeOption?.Extensions; }
public abstract bool ContinuePipeLineEntry <TB, TA>( IValueAndSupplement <TA, TB> pipeInput, out PipeBase <TB, TA> wrapInputIntoPipeBase, out IPipeOption pipeOption) where TA : new() where TB : new();
public override PipeBase <TV, TS> CreateSome(IValueAndSupplement <TV, TS> val, IPipeOption pipeOption) { var msgs = ExtractMessages(GetValue, GetSupplement); return(new Validator <TV, TS>(val, pipeOption, msgs)); }
public abstract PipeBase <TV, TS> CreateNone( IPipeOption pipeOption);
public override PipeBase <TV, TS> CreateValidation(IValueAndSupplement <TV, TS> val, IPipeOption pipeOption, System.ComponentModel.DataAnnotations.ValidationResult result) { var msgs = ExtractMessages(GetValue, GetSupplement); return(new Validator <TV, TS>(val, pipeOption, msgs)); }
public override PipeBase <TA, TB> CreateException <TA, TB>(Exception ex, IPipeOption pipeOption) { return(new SomeException <TA, TB>(ex, pipeOption)); }
public None(IPipeOption pipeOption) : base(pipeOption) { }
public abstract PipeBase <TA, TB> WrapPipeLineResult <TA, TB>( TA value, TB supplementedValue, IPipeOption pipeOption) where TA : new() where TB : new();
internal Validator(IPipeOption pipeOption, ValidationResult type, List <string> messages) { ConditionMet = pipeOption.ConditionIsMet; ExtensionInterfaces = pipeOption.Extensions; ValidatorType = type; }
public SomeException(Exception val, IPipeOption pipeOption) : base(pipeOption) { ExceptionVal = val; }
public override PipeBase <TV, TS> CreateValidation(IValueAndSupplement <TV, TS> val, IPipeOption pipeOption, ValidationResult result) { return(new Validation <TV, TS>(val, pipeOption, result)); }
public abstract PipeBase <TA, TB> CreateException <TA, TB>( Exception ex, IPipeOption pipeOption) where TA : new() where TB : new();