blob: 75e6d8439f1737041bda20566640b85efa6245ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
using System;
#if SILVERLIGHT
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
#endif
namespace TestCommon
{
public abstract class TestApp
{
protected static void test(bool b)
{
if(!b)
{
throw new System.Exception();
}
}
#if !SILVERLIGHT
static
#endif
public void Write(string msg)
{
#if SILVERLIGHT
Console.Out.Write(msg);
#else
Console.Out.Write(msg);
#endif
}
#if !SILVERLIGHT
static
#endif
public void WriteLine(string msg)
{
#if SILVERLIGHT
Console.Out.WriteLine(msg);
#else
Console.Out.WriteLine(msg);
#endif
}
#if !SILVERLIGHT
static
#endif
public void Flush()
{
Console.Out.Flush();
}
#if SILVERLIGHT
public abstract void run(Ice.Communicator communicator);
public virtual Ice.InitializationData
initData()
{
return new Ice.InitializationData();
}
public void main()
{
int args = Application.Current.Host.Source.OriginalString.IndexOf("?");
Dictionary<string, string> properties = new Dictionary<string, string>();
if(args > 0 && args + 1 < Application.Current.Host.Source.OriginalString.Length)
{
string[] props = Application.Current.Host.Source.OriginalString.Substring(args + 1).Split(';');
foreach (string prop in props)
{
int pos = prop.IndexOf('=');
if(pos > 0)
{
properties[prop.Substring(0, pos)] = prop.Substring(pos + 1);
}
}
}
System.Threading.Thread t = new System.Threading.Thread(() =>
{
Ice.Communicator communicator = null;
try
{
Ice.InitializationData initializationData = initData();
if(initializationData.properties == null)
{
initializationData.properties = Ice.Util.createProperties();
}
foreach(KeyValuePair<String,String> entry in properties)
{
if(initializationData.properties.getProperty(entry.Key).Equals(""))
{
initializationData.properties.setProperty(entry.Key, entry.Value);
}
}
communicator = Ice.Util.initialize(initializationData);
run(communicator);
completed();
}
catch(System.Exception ex)
{
failed(ex);
}
finally
{
if(communicator != null)
{
communicator.destroy();
}
}
});
t.Start();
}
public void completed()
{
Deployment.Current.Dispatcher.BeginInvoke(delegate()
{
Application.Current.MainWindow.Close();
});
}
public void failed(System.Exception ex)
{
System.Environment.ExitCode = 1;
WriteLine(Environment.NewLine + "Test Failed:");
WriteLine("Exception: " + ex.ToString());
completed();
}
#endif
}
}
|