using SmartCoalApplication.Base; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SmartCoalApplication { public static class Do { public static void Test( T value, Function testFn, Procedure ifTrueFn, Procedure ifFalseFn) { (testFn(value) ? ifTrueFn : ifFalseFn)(value); } public static void GenerateTest( Function generate, Function test, Procedure ifTrue, Procedure ifFalse) { Test(generate(), test, ifTrue, ifFalse); } public static bool TryBool(Procedure actionProcedure) { try { actionProcedure(); return true; } catch (Exception) { return false; } } public static T TryCatch( Function actionFunction, Function catchClause) { T returnVal; try { returnVal = actionFunction(); } catch (Exception ex) { returnVal = catchClause(ex); } return returnVal; } } }