summaryrefslogtreecommitdiff
path: root/csharp/test/Ice/exceptions/ThrowerAMDI.cs
blob: 61188a7e209622ca8c3f8f73daa3ece0405e8c08 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

using System;
using System.Diagnostics;
using System.Threading.Tasks;

namespace Ice
{
    namespace exceptions
    {
        namespace AMD
        {
            public class ThrowerI : Test.ThrowerDisp_
            {
                public ThrowerI()
                {
                }

                public override Task
                shutdownAsync(Ice.Current current)
                {
                    current.adapter.getCommunicator().shutdown();
                    return null;
                }

                public override Task<bool>
                supportsUndeclaredExceptionsAsync(Ice.Current current)
                {
                    return Task.FromResult(true);
                }

                public override Task<bool>
                supportsAssertExceptionAsync(Ice.Current current)
                {
                    return Task.FromResult(false);
                }

                public override Task
                throwAasAAsync(int a, Ice.Current current)
                {
                    throw new Test.A(a);
                }

                public override Task
                throwAorDasAorDAsync(int a, Ice.Current current)
                {
                    if(a > 0)
                    {
                        throw new Test.A(a);
                    }
                    else
                    {
                        throw new Test.D(a);
                    }
                }

                public override Task
                throwBasAAsync(int a, int b, Ice.Current current)
                {
                    //throw new B(a, b);
                    var s = new TaskCompletionSource<object>();
                    s.SetException(new Test.B(a, b));
                    return s.Task;
                }

                public override Task
                throwBasBAsync(int a, int b, Ice.Current current)
                {
                    throw new Test.B(a, b);
                }

                public override Task
                throwCasAAsync(int a, int b, int c, Ice.Current current)
                {
                    throw new Test.C(a, b, c);
                }

                public override Task
                throwCasBAsync(int a, int b, int c, Ice.Current current)
                {
                    throw new Test.C(a, b, c);
                }

                public override Task
                throwCasCAsync(int a, int b, int c, Ice.Current current)
                {
                    throw new Test.C(a, b, c);
                }

                public override Task
                throwUndeclaredAAsync(int a, Ice.Current current)
                {
                    throw new Test.A(a);
                }

                public override Task
                throwUndeclaredBAsync(int a, int b, Ice.Current current)
                {
                    throw new Test.B(a, b);
                }

                public override Task
                throwUndeclaredCAsync(int a, int b, int c, Ice.Current current)
                {
                    throw new Test.C(a, b, c);
                }

                public override Task
                throwLocalExceptionAsync(Ice.Current current)
                {
                    throw new Ice.TimeoutException();
                }

                public override Task
                throwNonIceExceptionAsync(Ice.Current current)
                {
                    throw new System.Exception();
                }

                public override Task
                throwAssertExceptionAsync(Ice.Current current)
                {
                    Debug.Assert(false);
                    return null;
                }

                public override Task<byte[]>
                throwMemoryLimitExceptionAsync(byte[] seq, Ice.Current current)
                {
                    return Task.FromResult(new byte[1024 * 20]); // 20KB is over the configured 10KB message size max.
                }

                public override Task
                throwLocalExceptionIdempotentAsync(Ice.Current current)
                {
                    throw new Ice.TimeoutException();
                }

                public override Task
                throwAfterResponseAsync(Ice.Current current)
                {
                    // Only supported with callback based AMD API
                    return null;
                    //throw new Exception();
                }

                public override Task
                throwAfterExceptionAsync(Ice.Current current)
                {
                    // Only supported with callback based AMD API
                    throw new Test.A();
                    //throw new Exception();
                }
            }
        }
    }
}