using System; namespace PaintDotNet { 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; } } }