PageRenderTime 35ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/Quickstarts/MultiTargeting/Silverlight/RealEstateListingViewer.Tests/App.xaml.cs

#
C# | 94 lines | 49 code | 6 blank | 39 comment | 1 complexity | 02e725ecc18ac4b500ce4f5400211b24 MD5 | raw file
  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. //===================================================================================
  18. // Microsoft patterns & practices
  19. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  20. //===================================================================================
  21. // Copyright (c) Microsoft Corporation. All rights reserved.
  22. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  23. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  24. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  25. // FITNESS FOR A PARTICULAR PURPOSE.
  26. //===================================================================================
  27. // The example companies, organizations, products, domain names,
  28. // e-mail addresses, logos, people, places, and events depicted
  29. // herein are fictitious. No association with any real company,
  30. // organization, product, domain name, email address, logo, person,
  31. // places, or events is intended or should be inferred.
  32. //===================================================================================
  33. using System;
  34. using System.Collections.Generic;
  35. using System.Linq;
  36. using System.Net;
  37. using System.Windows;
  38. using System.Windows.Controls;
  39. using System.Windows.Documents;
  40. using System.Windows.Input;
  41. using System.Windows.Media;
  42. using System.Windows.Media.Animation;
  43. using System.Windows.Shapes;
  44. using Microsoft.Silverlight.Testing;
  45. namespace RealEstateListingViewer.Tests
  46. {
  47. public partial class App : Application
  48. {
  49. public App()
  50. {
  51. this.Startup += this.Application_Startup;
  52. this.Exit += this.Application_Exit;
  53. this.UnhandledException += this.Application_UnhandledException;
  54. InitializeComponent();
  55. }
  56. private void Application_Startup(object sender, StartupEventArgs e)
  57. {
  58. this.RootVisual = UnitTestSystem.CreateTestPage();
  59. }
  60. private void Application_Exit(object sender, EventArgs e)
  61. {
  62. }
  63. private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
  64. {
  65. // If the app is running outside of the debugger then report the exception using
  66. // the browser's exception mechanism. On IE this will display it a yellow alert
  67. // icon in the status bar and Firefox will display a script error.
  68. if (!System.Diagnostics.Debugger.IsAttached)
  69. {
  70. // NOTE: This will allow the application to continue running after an exception has been thrown
  71. // but not handled.
  72. // For production applications this error handling should be replaced with something that will
  73. // report the error to the website and stop the application.
  74. e.Handled = true;
  75. try
  76. {
  77. string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
  78. errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
  79. System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");");
  80. }
  81. catch (Exception)
  82. {
  83. }
  84. }
  85. }
  86. }
  87. }