private static void DisplaySecurityMessage(SecurityException ex, string errorMessage) { bool wrapText = true; bool includeNewLine = true; if (errorMessage == null) { errorMessage = ""; } else if (errorMessage.Trim().Length > 0) { errorMessage = " " + errorMessage.Trim(); } Console.WriteLine(); ConsoleDisplayHelper.ShowHeadedText(0, "SecurityException:" + errorMessage + " You need to run this application as Administrator." + " Right-click the executable and select 'Run as administrator' from the" + " context menu.", wrapText, includeNewLine); Console.WriteLine(); ConsoleDisplayHelper.ShowHeadedText(1, "Exception Details: {0}", wrapText, includeNewLine, ex.Message); if (ex.InnerException != null) { ConsoleDisplayHelper.ShowHeadedText(2, "Inner Exception - {0}", wrapText, includeNewLine, ex.InnerException.Message); } }
private static void PrintConsoleLog(string logText, ConsoleDisplayType consoleDisplayType) { Console.ForegroundColor = ConsoleDisplayHelper.ReturnConsoleTextColor(consoleDisplayType); var logDescription = ConsoleDisplayHelper.GetEnumDescription(consoleDisplayType); var logFormattedText = $"> {DateTime.Now} {logDescription} {logText}"; Console.WriteLine(logFormattedText); Console.ForegroundColor = ConsoleColor.Gray; }
public static void DisplayXml() { try { string xmlText = "<truckContents><truck><key>235</key><shortName>Turners</shortName><longName>A & P Turners Ltd</longName></truck><orderSummary><totalItems>47</totalItems><totalWeight>322</totalWeight><totalVolume>6.5090</totalVolume></orderSummary><orders><order id=\"287451\" items=\"20\" weight=\"100\" volume=\"2.5\" /><order id=\"287498\" items=\"10\" weight=\"52\" volume=\"1.090\" /><order id=\"289562\" items=\"17\" weight=\"170\" volume=\"4.0\" /></orders></truckContents>"; ConsoleDisplayHelper.ShowXmlText(xmlText, 1, "Results:"); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayFormsMenu() { try { MenuForm form = new MenuForm(); form.ShowDialog(); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayJson() { try { string jsonText = "{\"firstName\": \"John\",\"lastName\": \"Smith\",\"age\": 25,\"address\": {\"streetAddress\": \"21 2nd Street\",\"city\": \"New York\",\"state\": \"NY\",\"postalCode\": 10021},\"phoneNumbers\": [{\"type\": \"home\",\"number\": \"212 555-1234\"},{\"type\": \"fax\",\"number\": \"646 555-4567\"}]}"; ConsoleDisplayHelper.ShowJsonText(jsonText, 1, "Results:"); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayAnObject() { try { MyLittleObject obj = new MyLittleObject(1, "String property"); ConsoleDisplayHelper.ShowObject(obj, 0, "{0} to display:", obj.GetType().Name); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayStringEnumeration() { try { List <string> stringList = new List <string>(new string[] { "AA", "BB" }); ConsoleDisplayHelper.ShowObject(stringList, 0, "String list to display:"); DisplayObjectViaForm(stringList); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayRecursiveObject() { try { RecursiveObject obj = new RecursiveObject(11); ConsoleDisplayHelper.ShowObject(obj, 0, "{0} to display:", obj.GetType()); DisplayObjectViaForm(obj); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayIndentedText() { try { string text = "This is the indented text"; ConsoleDisplayHelper.ShowIndentedText(2, text, false, true); DisplayTextViaForm(ObjectViewerForm.TextToDisplay.IndentedText); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayAComplexObject() { try { DemoClass1 obj = new DemoClass1(); ConsoleDisplayHelper.ShowObject(obj, 0, "{0} to display:", obj.GetType()); DisplayObjectViaForm(obj); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayNumberedText() { try { string text = "This is the numbered text"; ConsoleDisplayHelper.ShowNumberedText(3, 2, text, false); DisplayTextViaForm(ObjectViewerForm.TextToDisplay.NumberedText); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayNullDataTable() { try { DataTable table = null; ConsoleDisplayHelper.ShowDataTable(table, false); ObjectViewerForm viewerForm = new ObjectViewerForm(table); viewerForm.ShowDialog(); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplaySubTitle() { try { string title = "This is the sub-title"; string secondaryText = "This is some body text"; ConsoleDisplayHelper.ShowSubTitle(title); ConsoleDisplayHelper.ShowIndentedText(0, secondaryText, false, true); DisplayTextViaForm(ObjectViewerForm.TextToDisplay.SubTitle); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayException() { try { InvalidOperationException exception3 = new InvalidOperationException("Third level exception."); AccessViolationException exception2 = new AccessViolationException("Second level exception.", exception3); throw new ApplicationException("Top level exception.", exception2); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayValueEnumeration() { try { List <int> valueList = new List <int>(); valueList.Add(10); valueList.Add(20); ConsoleDisplayHelper.ShowObject(valueList, 0, "{0} to display:", valueList.GetType()); DisplayObjectViaForm(valueList); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayEmptyDataTable() { try { DataTable table = new DataTable("MyTable"); table.Columns.Add(new DataColumn("Col1", typeof(int))); table.Columns.Add(new DataColumn("Col2", typeof(string))); ConsoleDisplayHelper.ShowDataTable(table, false); ObjectViewerForm viewerForm = new ObjectViewerForm(table); viewerForm.ShowDialog(); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayObjectEnumeration() { try { List <MyLittleObject> objectList = new List <MyLittleObject>(new MyLittleObject[] { new MyLittleObject(1, "ListObject1"), new MyLittleObject(2, "ListObject2") }); ConsoleDisplayHelper.ShowObject(objectList, 0, "{0} to display:", objectList.GetType()); DisplayObjectViaForm(objectList); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }
public static void DisplayHeadedText() { try { string mainText; mainText = "Header: Normal text"; ConsoleDisplayHelper.ShowHeadedText(2, mainText, false, true); mainText = "Header (type: MyType): Normal text"; ConsoleDisplayHelper.ShowHeadedText(2, mainText, false, true); mainText = "All normal text"; ConsoleDisplayHelper.ShowHeadedText(2, mainText, false, true); DisplayTextViaForm(ObjectViewerForm.TextToDisplay.HeadedText); } catch (Exception xcp) { ConsoleDisplayHelper.ShowException(1, xcp); } }