Debian Codegraph @

external/rx/Rx/NET/Source/Tests.System.Reactive/App.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 #if SILVERLIGHT && !SILVERLIGHTM7
4 using System;
5 using System.Diagnostics;
6 using System.Windows;
7 using System.Windows.Browser;
8 using Microsoft.Silverlight.Testing;
9
10 namespace ReactiveTests
11 {
12 public class App : Application
13 {
14 public App()
15 {
16 this.Startup += (o, e) =>
17 {
18 // TODO: Investigate UnitTestSettings configuration of TestService and LogProviders.
19 // var settings = new UnitTestSettings { StartRunImmediately = true };
20 RootVisual = UnitTestSystem.CreateTestPage(/* settings */);
21 };
22
23 this.UnhandledException += (o, e) =>
24 {
25 if (!Debugger.IsAttached)
26 {
27 e.Handled = true;
28 Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
29 }
30 };
31 }
32
33 private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
34 {
35 try
36 {
37 string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
38 errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
39
40 HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
41 }
42 catch (Exception)
43 {
44 }
45 }
46 }
47 }
48 #endif