/// <summary> /// Validates a condition to be true with defered formating of error message /// with ErrReportException thrown on failure /// </summary> /// <param name="condition">The condition to evaluate</param> /// <param name="code">The error code if false</param> /// <param name="msg">The error message function</param> public static void ChkTrue(bool condition, int code, Func <string> msgFunc) { if (!condition) { // Format method only invoked on failure of condition WrapErr.ChkTrue(condition, code, WrapErr.SafeAction(msgFunc)); } }
/// <summary> /// Validates a string not null and not empty with standard error message /// and ErrReportException on failure /// </summary> /// <param name="nullCode">Error code if string is null</param> /// <param name="zeroLenCode">Error code if string is empty</param> /// <param name="name">The string variable name</param> /// <param name="value">The string value to evaluate</param> public static void ChkStr(int nullCode, int zeroLenCode, string name, string value) { WrapErr.ChkTrue(value != null, nullCode, () => { return(String.Format("String '{0}' is Null", name)); }); WrapErr.ChkTrue(value.Trim().Length > 0, zeroLenCode, () => { return(String.Format("String '{0}' is Empty", name)); }); }