2003-02-03 Patrik Torstensson
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Messaging / ReturnMessage.cs
1 //
2 // System.Runtime.Remoting.Messaging.ReturnMessage.cs
3 //
4 // Author:
5 //   Dietmar Maurer (dietmar@ximian.com)
6 //
7 // (C) Ximian, Inc.  http://www.ximian.com
8 //
9
10 using System;
11 using System.Collections;
12 using System.Reflection;
13
14 namespace System.Runtime.Remoting.Messaging {
15
16         [Serializable]
17         public class ReturnMessage : IMethodReturnMessage, IMethodMessage \r
18         {
19                 MonoMethodMessage msg;
20                 IMethodCallMessage request;
21                 
22                 public ReturnMessage (object returnValue, object [] outArgs,
23                                int outArgCount, LogicalCallContext callCtx,
24                                IMethodCallMessage request)
25                 {
26                         // fixme: request can be null
27                         // fixme: why do we need outArgCount?
28                         msg = new MonoMethodMessage (request.MethodBase as MonoMethod, outArgs);
29                         this.request = request;
30                         msg.rval = returnValue;
31                         msg.ctx = callCtx;
32                         msg.Uri = request.Uri;
33                 }
34
35                 public ReturnMessage (Exception exc, IMethodCallMessage request)
36                 {
37                         if (null != request) {
38                                 msg = new MonoMethodMessage (request.MethodBase as MonoMethod, null);
39                                 msg.ctx = request.LogicalCallContext;
40                         }
41                         else
42                                 msg = new MonoMethodMessage (null, null);
43
44                         this.request = request;
45                         msg.exc = exc;
46                 }
47                 
48                 public int ArgCount {
49                         get {
50                                 return msg.ArgCount;
51                         }
52                 }
53                 
54                 public object [] Args {
55                         get {
56                                 return msg.Args;
57                         }
58                 }
59                 
60                 public bool HasVarArgs {
61                         get {
62                                 return msg.HasVarArgs;
63                         }
64                 }
65
66                 public LogicalCallContext LogicalCallContext {
67                         get {
68                                 if (null == msg)
69                                         return null;
70                                 return msg.ctx;
71                         }
72                 }
73
74                 public MethodBase MethodBase {
75                         get {
76                                 return msg.MethodBase;
77                         }
78                 }
79
80                 public string MethodName {
81                         get {
82                                 return msg.MethodName;
83                         }
84                 }
85
86                 public object MethodSignature {
87                         get {
88                                 return msg.MethodSignature;
89                         }
90                 }
91
92                 public virtual IDictionary Properties {
93                         get {
94                                 return msg.Properties;
95                         }
96                 }
97
98                 public string TypeName {
99                         get {
100                                 return msg.TypeName;
101                         }
102                 }
103
104                 public string Uri {
105                         get {
106                                 return msg.Uri;
107                         }
108
109                         set {
110                                 msg.Uri = value;
111                         }
112                 }
113
114                 public object GetArg (int arg_num)
115                 {
116                         return msg.GetArg (arg_num);
117                 }
118                 
119                 public string GetArgName (int arg_num)
120                 {
121                         return msg.GetArgName (arg_num);
122                 }
123
124                 public Exception Exception {
125                         get {
126                                 return msg.exc;
127                         }
128                 }
129
130                 public int OutArgCount {
131                         get {
132                                 return msg.OutArgCount;
133                         }
134                 }
135
136                 public object [] OutArgs {
137                         get {
138                                 return msg.OutArgs;
139                         }
140                 }
141
142                 public virtual object ReturnValue {
143                         get {
144                                 return msg.rval;
145                         }
146                 }
147
148                 public object GetOutArg (int arg_num)
149                 {
150                         return msg.GetOutArg (arg_num);
151                 }
152
153                 public string GetOutArgName (int arg_num)
154                 {
155                         return msg.GetOutArgName (arg_num);
156                 }
157
158
159                 class InternalDictionary : MethodReturnDictionary\r
160                 {\r
161                         public InternalDictionary(ReturnMessage message) : base (message) { }\r
162
163                         protected override void SetMethodProperty (string key, object value)
164                         {
165                                 if (key == "__Uri") ((ReturnMessage)_message).Uri = (string)value;
166                                 else base.SetMethodProperty (key, value);
167                         }
168                 }\r
169         }
170 }