public static void ReportErrorIf <T>(bool condition, ReportMechanism reportMechanism, string message, string title) where T : Exception { if (condition) { ReportError <T>(reportMechanism, message, title); } }
public static void ReportError <T>(ReportMechanism reportMechanism, string message, string title) where T : Exception { switch (reportMechanism) { case ReportMechanism.Console: System.Console.WriteLine(title + ": " + message); break; case ReportMechanism.Debug: System.Diagnostics.Debug.WriteLine(title + ": " + message); break; case ReportMechanism.Dialog: OSMessageBox.Show(message, title, OSMessageBoxButton.OK, OSMessageBoxIcon.Error); break; case ReportMechanism.Exception: throw (Exception)Activator.CreateInstance(typeof(T), message); } }
public static void ReportNotImplemented(ReportMechanism reportMechanism, string message) { ReportError <NotImplementedException>(reportMechanism, message, "Not Implemented"); }
public static void ReportError(ReportMechanism reportMechanism, string message) { ReportError <Exception>(reportMechanism, message, "Error"); }