PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/SuperMemory/App.xaml.cs

https://github.com/antonkulaga/SuperMemory
C# | 69 lines | 53 code | 9 blank | 7 comment | 1 complexity | 8be4b58bbbb8e92672cff25cb6120c11 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. using SuperMemory.Order;
  13. namespace SuperMemory
  14. {
  15. public partial class App : Application
  16. {
  17. public App()
  18. {
  19. this.Startup += this.Application_Startup;
  20. this.Exit += this.Application_Exit;
  21. this.UnhandledException += this.Application_UnhandledException;
  22. InitializeComponent();
  23. }
  24. private void Application_Startup(object sender, StartupEventArgs e)
  25. {
  26. this.RootVisual = new OrderPage();
  27. }
  28. private void Application_Exit(object sender, EventArgs e)
  29. {
  30. }
  31. private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
  32. {
  33. // If the app is running outside of the debugger then report the exception using
  34. // the browser's exception mechanism. On IE this will display it a yellow alert
  35. // icon in the status bar and Firefox will display a script error.
  36. if (!System.Diagnostics.Debugger.IsAttached)
  37. {
  38. // NOTE: This will allow the application to continue running after an exception has been thrown
  39. // but not handled.
  40. // For production applications this error handling should be replaced with something that will
  41. // report the error to the website and stop the application.
  42. e.Handled = true;
  43. Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
  44. }
  45. }
  46. private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
  47. {
  48. try
  49. {
  50. string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
  51. errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
  52. System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
  53. }
  54. catch (Exception)
  55. {
  56. }
  57. }
  58. }
  59. }