-
Notifications
You must be signed in to change notification settings - Fork 659
/
Copy pathDelegateTest.cs
708 lines (592 loc) · 23.6 KB
/
DelegateTest.cs
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
using ILRuntimeTest;
using ILRuntimeTest.TestFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace TestCases
{
public class DelegateTest
{
static TestDelegate testDele;
public static void DelegateTest01()
{
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest += IntTest;
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest += IntTest2;
DelegateTestCls cls = new DelegateTestCls(1000);
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest += cls.IntTest;
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest += cls.IntTest2;
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest(123);
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateEventTest += IntTest;
ILRuntimeTest.TestFramework.DelegateTest.TestEvent();
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateEventTest -= IntTest;
ILRuntimeTest.TestFramework.DelegateTest test = new ILRuntimeTest.TestFramework.DelegateTest();
test.IntDelegateEventTest2 += IntTest;
test.TestEvent2();
test.IntDelegateEventTest2 -= IntTest;
}
public static void DelegateTest02()
{
Action<int> a = null;
a += IntTest;
a += IntTest2;
DelegateTestCls cls = new DelegateTestCls(1000);
a += cls.IntTest;
a += cls.IntTest2;
a += (i) =>
{
Console.WriteLine("lambda a=" + i);
};
a(123);
}
public static int DelegateTest03()
{
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 += IntTest3;
DelegateTestCls cls = new DelegateTestCls(1000);
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 += cls.IntTest3;
int val = ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2(123);
return val;
}
delegate int TestDelegate(int b);
public static int DelegateTest04()
{
Func<int, int> a = null;
a += IntTest3;
DelegateTestCls cls = new DelegateTestCls(1000);
a += cls.IntTest3;
a += (i) =>
{
Console.WriteLine("lambda a=" + i);
return i + 300;
};
int val = a(123);
return val;
}
public static int DelegateTest05()
{
testDele += IntTest3;
DelegateTestCls cls = new DelegateTestCls(1000);
testDele += cls.IntTest3;
int val = testDele(123);
return val;
}
public static void DelegateTest06()
{
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest = null;
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest += IntTest;
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest -= IntTest;
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest += IntTest2;
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest(1000);
}
public static void DelegateTest07()
{
Test07Sub(IntTest);
Test07Sub2(IntTest);
}
public static void DelegateTest08()
{
testDele = null;
testDele += IntTest3;
testDele -= IntTest3;
testDele += IntTest3;
Console.WriteLine(testDele(1000));
}
public static void DelegateTest09()
{
Test09Sub(IntTest3);
Test09Sub2(IntTest3);
}
public static void DelegateTest10()
{
Action<int, string, string> a = (b, c, d) =>
{
Action act = () =>
{
Console.WriteLine(string.Format("{0},{1},{2}", b, c, d));
};
act();
};
a(1, "2", "3");
}
public static void DelegateTest11()
{
ILRuntimeTest.TestFramework.DelegateTest.GenericDelegateTest = CallBack;
ILRuntimeTest.TestFramework.BaseClassTest.DoTest();
}
public static void DelegateTest12()
{
testDele += IntTest3;
Dictionary<int, TestDelegate> dic = new Dictionary<int, TestDelegate>();
dic[0] = testDele;
dic[1] = IntTest3;
Console.WriteLine(dic[0](1000));
Console.WriteLine(dic[1](1000));
}
public static void DelegateTest13()
{
Action<int> a = null;
a += IntTest;
a += IntTest2;
a -= IntTest;
a -= IntTest2;
Console.WriteLine(a == null);
}
public static void DelegateTest14()
{
Action<string> a = null;
a += TestString;
a += TestString2;
a += TestString3;
a += TestString4;
a("ffff");
}
public static void DelegateTest15()
{
DelegateTestCls cls = new DelegateTestCls(123);
DelegateTest15Sub(cls.IntTest);
}
static void DelegateTest15Sub(Action<int> test)
{
test(555);
}
public static void DelegateTest16()
{
System.Action a = () => { };
System.Action<int> a_2 = (i) => { };
int a3 = 2;
Console.WriteLine(typeof(System.Action) == a.GetType()); //false, should be true
Console.WriteLine(typeof(int) == a3.GetType()); //false, should be true
}
public static void DelegateTest17()
{
Action a = () => { };
Console.WriteLine(a.GetHashCode());
}
public static void DelegateTest18()
{
ILRuntimeTest.TestFramework.DelegateTest.EnumDelegateTest = DelegateTest18Sub;
ILRuntimeTest.TestFramework.DelegateTest.TestEnumDelegate();
}
static void DelegateTest18Sub(ILRuntimeTest.TestFramework.TestCLREnum e)
{
switch (e)
{
case ILRuntimeTest.TestFramework.TestCLREnum.Test1:
Console.WriteLine("Test1");
break;
case ILRuntimeTest.TestFramework.TestCLREnum.Test2:
Console.WriteLine("Test2");
break;
case ILRuntimeTest.TestFramework.TestCLREnum.Test3:
Console.WriteLine("Test3");
break;
default:
throw new Exception("Should not be here");
}
}
public static void DelegateTest19()
{
ILRuntimeTest.TestFramework.DelegateTest.EnumDelegateTest2 = DelegateTest19Sub;
ILRuntimeTest.TestFramework.DelegateTest.TestEnumDelegate2();
}
static ILRuntimeTest.TestFramework.TestCLREnum DelegateTest19Sub()
{
return ILRuntimeTest.TestFramework.TestCLREnum.Test2;
}
static int test20Val;
public static void DelegateTest20()
{
test20Val = 0;
Action<int> act = (b) => test20Val += b + 2;
act += (b) => test20Val += b + 3;
act(1);
if (test20Val != 7)
throw new Exception(test20Val.ToString());
test20Val = 0;
List<Action<int>> lst = new List<Action<int>>();
lst.Add(act);
lst[0](1);
if (test20Val != 7)
throw new Exception(test20Val.ToString());
}
public static void DelegateTest21()
{
test20Val = 0;
Func<int, int> act = (b) => test20Val += b + 2;
act += (b) => test20Val += b + 3;
var val = act(1);
if (val != 7)
throw new Exception(test20Val.ToString());
test20Val = 0;
List<Func<int, int>> lst = new List<Func<int, int>>();
lst.Add(act);
val = lst[0](1);
if (val != 7)
throw new Exception(test20Val.ToString());
}
public static void DelegateTest22()
{
DelegateTest22Sub<string, Object>("11", "22", DelegateTest22Sub2);
}
static void DelegateTest22Sub<T, U>(string str, Object obj, Action<T, U> action)
{
Action<string, Object> callback = action as Action<string, Object>;//在此用as转换为泛型委托时,提示空引用
callback(str, obj);
}
static void DelegateTest22Sub2(string str, Object obj)
{
string res = str + obj;
if (res != "1122")
throw new Exception();
}
static void TestString(string a)
{
Console.WriteLine("test1:" + a);
}
static void TestString2(string a)
{
Console.WriteLine("test2:" + a);
}
static void TestString3(string a)
{
Console.WriteLine("test3:" + a);
}
static void TestString4(string a)
{
Console.WriteLine("test4:" + a);
}
static void CallBack(ILRuntimeTest.TestFramework.BaseClassTest a)
{
a.testField = true;
Console.WriteLine(a.testField);
}
static void Test07Sub(ILRuntimeTest.TestFramework.IntDelegate action)
{
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest = action;
}
static void Test07Sub2(ILRuntimeTest.TestFramework.IntDelegate action)
{
Console.WriteLine("Test Result=" + (ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest == action));
}
static void Test09Sub(TestDelegate action)
{
testDele = action;
}
static void Test09Sub2(TestDelegate action)
{
Console.WriteLine("Test Result=" + (testDele == action));
}
static void IntTest(int a)
{
Console.WriteLine("dele a=" + a);
}
static void IntTest2(int a)
{
Console.WriteLine("dele2 a=" + a);
}
static int IntTest3(int a)
{
Console.WriteLine("dele3 a=" + a);
return a + 100;
}
static void FacadeAction(bool v)
{
Console.WriteLine(v);
}
public static void DelegateTest23()
{
DelegateTestCls.FacadeAction = FacadeAction;
DelegateTestCls.FacadeAction2 = FacadeAction;
DelegateTestCls.FacadeAction3 = FacadeAction;
DelegateTestCls.FacadeAction4 = FacadeAction;
DelegateTest23Sub();
}
static float[] ParamArray = new float[4];
static void DelegateTest23Sub()
{
DelegateTestCls.FacadeAction?.Invoke(1 == ParamArray[0] ? true : false);
DelegateTestCls.FacadeAction2?.Invoke(1 == ParamArray[1] ? true : false);
DelegateTestCls.FacadeAction3?.Invoke(1 == ParamArray[2] ? true : false);
DelegateTestCls.FacadeAction4?.Invoke(1 == ParamArray[3] ? true : false);
}
class DelegateTestCls : DelegateTestClsBase
{
public static Action<bool> FacadeAction;
public static Action<bool> FacadeAction2;
public static Action<bool> FacadeAction3;
public static Action<bool> FacadeAction4;
public DelegateTestCls(int b)
{
this.b = b;
}
public override void IntTest(int a)
{
base.IntTest(a);
Console.WriteLine("dele3 a=" + (a + b));
}
public override int IntTest3(int a)
{
Console.WriteLine("dele5 a=" + a);
return a + 200;
}
}
class DelegateTestClsBase
{
protected int b;
public virtual void IntTest(int a)
{
Console.WriteLine("dele3base a=" + (a + b));
}
public virtual void IntTest2(int a)
{
Console.WriteLine("dele4 a=" + (a + b));
}
public virtual int IntTest3(int a)
{
return a + b;
}
}
public static void DelegateTest24()
{
List<ILRuntimeTest.TestFramework.TestVector3> list = new List<ILRuntimeTest.TestFramework.TestVector3>();
list.Add(new ILRuntimeTest.TestFramework.TestVector3(1, 2, 3));
list.Add(new ILRuntimeTest.TestFramework.TestVector3(2, 3, 4));
list.Add(new ILRuntimeTest.TestFramework.TestVector3(3, 4, 5));
var res = list.Sum(v => v.X);
Console.WriteLine(res);
if (res != 6)
throw new Exception();
}
public static void DelegateTest25()
{
testDele = Delegate.CreateDelegate(typeof(TestDelegate), typeof(DelegateTest).GetMethod(nameof(IntTest3))) as TestDelegate;
var res = testDele(100);
if (res != 200)
throw new Exception();
}
[ILRuntimeTest(IsToDo = true)]
public static void DelegateTest26()
{
testDele = Delegate.CreateDelegate(typeof(TestDelegate), typeof(ILRuntimeTest.TestFramework.DelegateTest).GetMethod(nameof(ILRuntimeTest.TestFramework.DelegateTest.TestIntDelegate))) as TestDelegate;
var res = testDele(100);
if (res != 200)
throw new Exception();
}
[ILRuntimeTest(IsToDo = true)]
public static void DelegateTest27()
{
testDele = ILRuntimeTest.TestFramework.DelegateTest.TestIntDelegate;
var res = testDele(100);
if (res != 200)
throw new Exception();
}
public static void DelegateTest28()
{
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = Delegate.CreateDelegate(typeof(IntDelegate2), typeof(DelegateTest).GetMethod(nameof(IntTest3))) as IntDelegate2;
var res = ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2(100);
if (res != 200)
throw new Exception();
}
public static void DelegateTest29()
{
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = Delegate.CreateDelegate(typeof(IntDelegate2), typeof(ILRuntimeTest.TestFramework.DelegateTest).GetMethod(nameof(ILRuntimeTest.TestFramework.DelegateTest.TestIntDelegate))) as IntDelegate2;
var res = ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2(100);
if (res != 333)
throw new Exception();
}
public static void DelegateTest30()
{
DelegateTestCls cls = new DelegateTestCls(100);
testDele = Delegate.CreateDelegate(typeof(TestDelegate), cls, nameof(DelegateTestCls.IntTest3)) as TestDelegate;
var res = testDele(100);
if (res != 300)
throw new Exception();
}
public static void DelegateTest31()
{
DelegateTestCls cls = new DelegateTestCls(100);
testDele = Delegate.CreateDelegate(typeof(TestDelegate), cls, typeof(DelegateTestCls).GetMethod(nameof(DelegateTestCls.IntTest3))) as TestDelegate;
var res = testDele(100);
if (res != 300)
throw new Exception();
}
public static void DelegateTest32()
{
DelegateTestCls cls = new DelegateTestCls(100);
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = Delegate.CreateDelegate(typeof(IntDelegate2), cls, nameof(DelegateTestCls.IntTest3)) as IntDelegate2;
var res = ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2(100);
if (res != 300)
throw new Exception();
}
public static void DelegateTest33()
{
DelegateTestCls cls = new DelegateTestCls(100);
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = Delegate.CreateDelegate(typeof(IntDelegate2), cls, typeof(DelegateTestCls).GetMethod(nameof(DelegateTestCls.IntTest3))) as IntDelegate2;
var res = ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2(100);
if (res != 300)
throw new Exception();
}
public static void DelegateTest34()
{
ILRuntimeTest.TestFramework.DelegateTest cls = new ILRuntimeTest.TestFramework.DelegateTest();
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = Delegate.CreateDelegate(typeof(IntDelegate2), cls, nameof(ILRuntimeTest.TestFramework.DelegateTest.TestIntDelegateInstance)) as IntDelegate2;
var res = ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2(100);
if (res != 999)
throw new Exception();
}
public static void DelegateTest35()
{
ILRuntimeTest.TestFramework.DelegateTest cls = new ILRuntimeTest.TestFramework.DelegateTest();
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = Delegate.CreateDelegate(typeof(IntDelegate2), cls, typeof(ILRuntimeTest.TestFramework.DelegateTest).GetMethod(nameof(ILRuntimeTest.TestFramework.DelegateTest.TestIntDelegateInstance))) as IntDelegate2;
var res = ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2(100);
if (res != 999)
throw new Exception();
}
class B
{
}
class A
{
public int a = 123;
private void test(B b)
{
if (b != null && b.GetType() == typeof(B) && a == 123)
Console.WriteLine("OK");
else
throw new Exception();
}
public static void Test2(B b)
{
if (b != null && b.GetType() == typeof(B))
Console.WriteLine("OK2");
else
throw new Exception();
}
}
delegate void TestDele(B a);
public static void DelegateTest36()
{
A target = new A();
Type type = target.GetType();
MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Instance);
for (int methodInfoIndex = 0; methodInfoIndex < methodInfos.Length; methodInfoIndex++)
{
MethodInfo methodInfo = methodInfos[methodInfoIndex];
ParameterInfo[] parameterInfos = methodInfo.GetParameters();
Type actionType = typeof(Action<>).MakeGenericType(parameterInfos[0].ParameterType);
Delegate action = Delegate.CreateDelegate(actionType, target, methodInfo);
action.DynamicInvoke(new B());
}
}
public static void DelegateTest37()
{
A target = new A();
Type type = target.GetType();
MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Instance);
for (int methodInfoIndex = 0; methodInfoIndex < methodInfos.Length; methodInfoIndex++)
{
MethodInfo methodInfo = methodInfos[methodInfoIndex];
Type actionType = typeof(TestDele);
Delegate action = Delegate.CreateDelegate(actionType, target, methodInfo);
action.DynamicInvoke(new B());
}
}
public static void DelegateTest38()
{
A target = new A();
Type type = target.GetType();
MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Instance);
for (int methodInfoIndex = 0; methodInfoIndex < methodInfos.Length; methodInfoIndex++)
{
MethodInfo methodInfo = methodInfos[methodInfoIndex];
Type actionType = typeof(TestDele);
Delegate action = methodInfo.CreateDelegate(actionType, target);
action.DynamicInvoke(new B());
}
}
public static void DelegateTest39()
{
A target = new A();
Type type = target.GetType();
MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Static);
for (int methodInfoIndex = 0; methodInfoIndex < methodInfos.Length; methodInfoIndex++)
{
MethodInfo methodInfo = methodInfos[methodInfoIndex];
Type actionType = typeof(TestDele);
Delegate action = methodInfo.CreateDelegate(actionType, null);
action.DynamicInvoke(new B());
}
}
public static void DelegateTest40()
{
A target = new A();
Type type = target.GetType();
MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Static);
for (int methodInfoIndex = 0; methodInfoIndex < methodInfos.Length; methodInfoIndex++)
{
MethodInfo methodInfo = methodInfos[methodInfoIndex];
Type actionType = typeof(TestDele);
Delegate action = methodInfo.CreateDelegate(actionType);
action.DynamicInvoke(new B());
}
}
public static void DelegateTest41()
{
BindableProperty<long> t = new BindableProperty<long>(10000);
t.OnChangeWithOldVal += Message;
t.Value = 1234;
}
public static void DelegateTest42()
{
ILRuntimeTest.TestFramework.DelegateTest cls = new ILRuntimeTest.TestFramework.DelegateTest();
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = cls.TestIntDelegateInstance;
if (ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2.Target != cls)
throw new Exception();
ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2 = ILRuntimeTest.TestFramework.DelegateTest.TestIntDelegate;
if (ILRuntimeTest.TestFramework.DelegateTest.IntDelegateTest2.Target != null)
throw new Exception();
DelegateTestCls cls2 = new DelegateTestCls(100);
testDele = cls2.IntTest3;
if (testDele.Target != cls2)
throw new Exception();
testDele = IntTest3;
if (testDele.Target != null)
throw new Exception();
}
static event Action<float, double, int> OnIntEvent;
static void Message<T>(T oldVal, T newVal)
{
Console.WriteLine(typeof(T));
Console.WriteLine(oldVal);
Console.WriteLine(newVal);
}
public static void DelegateTest43()
{
OnIntEvent += DelegateTest43Sub;
OnIntEvent(1, 2, 3);
OnIntEvent -= DelegateTest43Sub;
if (OnIntEvent != null)
throw new Exception();
}
static void DelegateTest43Sub(float a, double b, int c)
{
if (a != 1 || b != 2 || c != 3)
throw new Exception();
Console.WriteLine($"a={a}, b={b}, c={c}");
}
public static void DelegateTest44()
{
ILRuntimeTest.TestBase.TestSession.LastSession.Appdomain.AllowUnboundCLRMethod = false;
}
public static void DelegateTest45()
{
ILRuntimeTest.TestFramework.DelegateTest.OnIntEvent += DelegateTest43Sub;
ILRuntimeTest.TestFramework.DelegateTest.TestEvent3(1, 2, 3);
ILRuntimeTest.TestFramework.DelegateTest.OnIntEvent -= DelegateTest43Sub;
ILRuntimeTest.TestBase.TestSession.LastSession.Appdomain.AllowUnboundCLRMethod = true;
if (!ILRuntimeTest.TestFramework.DelegateTest.TestEvent4())
throw new Exception();
}
}
}