/// <summary> /// Run Common If Code Schema with Validation /// Schema : Init --> Pre --> Validate --> /// ((Process or ValidFalse or ValidNull) or Fail) /// --> Post --> End. /// Check methods Init and End methods return bool? results and run CheckTrue/CheckFalse/CheckNull methods if available /// or return default on not true /// </summary> public static ResT I <ParamT, ResT>(Pr <ParamT, ResT> ProcessToRun, Cx CurrCodeType = null) { if (ProcessToRun.V == null && ProcessToRun.Vn == null) { return(ProcessToRun.D); } Pr <ParamT, ResT> Res = ProcessToRun; Res.Vt = (param, code) => { bool?Validated = true; ResT Result = ProcessToRun.D; if (ProcessToRun.V != null) { Validated = ProcessToRun.V(param, CurrCodeType); } if (Validated == null) { if (ProcessToRun.Vn != null) { Result = ProcessToRun.Vn(param, CurrCodeType); } else if (ProcessToRun.F != null) { Result = ProcessToRun.F(param, CurrCodeType); } } else if (Validated == false) { if (ProcessToRun.Vf != null) { Result = ProcessToRun.Vf(param, CurrCodeType); } else if (ProcessToRun.F != null) { Result = ProcessToRun.F(param, CurrCodeType); } } else if (ProcessToRun.Vt != null) { Result = ProcessToRun.Vt(param, CurrCodeType); } else if (ProcessToRun.F != null) { Result = ProcessToRun.F(param, CurrCodeType); } return(Result); }; return(F(Res, CurrCodeType)); }
/// <summary> /// Run Common Try Code Schema Block With Errors And Performance Logging based on CurrCodeType. /// Schema : Init --> Pre --> Validate --> /// try[CustomUseTryCatch or CurrCodeType] /// ((Process or ValidFalse or ValidNull) or Fail) with Error OnErrorCatch /// --> Post --> End. /// Check methods Init and End methods return bool? results and run CheckTrue/CheckFalse/CheckNull methods if available /// or return default on not true /// </summary> public static ResT Ti <ParamT, ResT>(Pr <ParamT, ResT> ProcessToRun, Cx CurrCodeType = null) { bool UseTryCatch = CurrCodeType != null && CurrCodeType.T; Pr <ParamT, ResT> Res = ProcessToRun; Res.Vt = (param, code) => { bool?Validated = true; ResT Result = ProcessToRun.D; if (ProcessToRun.V != null) { Validated = ProcessToRun.V(param, CurrCodeType); } if (Validated == null) { if (ProcessToRun.Vn != null) { Result = ProcessToRun.Vn(param, CurrCodeType); } else if (ProcessToRun.F != null) { Result = ProcessToRun.F(param, CurrCodeType); } } else if (Validated == false) { if (ProcessToRun.Vf != null) { Result = ProcessToRun.Vf(param, CurrCodeType); } else if (ProcessToRun.F != null) { Result = ProcessToRun.F(param, CurrCodeType); } } else if (ProcessToRun.Vt != null) { Result = ProcessToRun.Vt(param, CurrCodeType); } else if (ProcessToRun.F != null) { Result = ProcessToRun.F(param, CurrCodeType); } return(Result); }; return(T(Res, CurrCodeType)); }