summaryrefslogtreecommitdiff
path: root/csharp/test/Ice/invoke/BlobjectI.cs
blob: 3b7b32ede6941653e8435feedbe15cd87c8ca900 (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
// **********************************************************************
//
// Copyright (c) 2003-present ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

using System.Threading.Tasks;

namespace Ice
{
    namespace invoke
    {
        public class BlobjectI : Ice.Blobject
        {
            public override bool
            ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
            {
                Ice.Communicator communicator = current.adapter.getCommunicator();
                Ice.InputStream inS = new Ice.InputStream(communicator, inParams);
                inS.startEncapsulation();
                Ice.OutputStream outS = new Ice.OutputStream(communicator);
                outS.startEncapsulation();
                if(current.operation.Equals("opOneway"))
                {
                    outParams = new byte[0];
                    return true;
                }
                else if(current.operation.Equals("opString"))
                {
                    string s = inS.readString();
                    outS.writeString(s);
                    outS.writeString(s);
                    outS.endEncapsulation();
                    outParams = outS.finished();
                    return true;
                }
                else if(current.operation.Equals("opException"))
                {
                    if(current.ctx.ContainsKey("raise"))
                    {
                        throw new Test.MyException();
                    }
                    var ex = new Test.MyException();
                    outS.writeException(ex);
                    outS.endEncapsulation();
                    outParams = outS.finished();
                    return false;
                }
                else if(current.operation.Equals("shutdown"))
                {
                    communicator.shutdown();
                    outParams = null;
                    return true;
                }
                else if(current.operation.Equals("ice_isA"))
                {
                    string s = inS.readString();
                    if(s.Equals("::Test::MyClass"))
                    {
                        outS.writeBool(true);
                    }
                    else
                    {
                        outS.writeBool(false);
                    }
                    outS.endEncapsulation();
                    outParams = outS.finished();
                    return true;
                }
                else
                {
                    Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
                    ex.id = current.id;
                    ex.facet = current.facet;
                    ex.operation = current.operation;
                    throw ex;
                }
            }
        }

        public class BlobjectAsyncI : Ice.BlobjectAsync
        {
            public override Task<Ice.Object_Ice_invokeResult>
            ice_invokeAsync(byte[] inParams, Ice.Current current)
            {
                Ice.Communicator communicator = current.adapter.getCommunicator();
                Ice.InputStream inS = new Ice.InputStream(communicator, inParams);
                inS.startEncapsulation();
                Ice.OutputStream outS = new Ice.OutputStream(communicator);
                outS.startEncapsulation();
                if(current.operation.Equals("opOneway"))
                {
                    return Task.FromResult(new Ice.Object_Ice_invokeResult(true, new byte[0]));
                }
                else if(current.operation.Equals("opString"))
                {
                    string s = inS.readString();
                    outS.writeString(s);
                    outS.writeString(s);
                    outS.endEncapsulation();
                    return Task.FromResult(new Ice.Object_Ice_invokeResult(true, outS.finished()));
                }
                else if(current.operation.Equals("opException"))
                {
                    Test.MyException ex = new Test.MyException();
                    outS.writeException(ex);
                    outS.endEncapsulation();
                    return Task.FromResult(new Ice.Object_Ice_invokeResult(false, outS.finished()));
                }
                else if(current.operation.Equals("shutdown"))
                {
                    communicator.shutdown();
                    return Task.FromResult(new Ice.Object_Ice_invokeResult(true, null));
                }
                else if(current.operation.Equals("ice_isA"))
                {
                    string s = inS.readString();
                    if(s.Equals("::Test::MyClass"))
                    {
                        outS.writeBool(true);
                    }
                    else
                    {
                        outS.writeBool(false);
                    }
                    outS.endEncapsulation();
                    return Task.FromResult(new Ice.Object_Ice_invokeResult(true, outS.finished()));
                }
                else
                {
                    Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
                    ex.id = current.id;
                    ex.facet = current.facet;
                    ex.operation = current.operation;
                    throw ex;
                }
            }
        }
    }
}