2 // System.Runtime.Remoting.Messaging.MonoMethodMessage.cs
5 // Dietmar Maurer (dietmar@ximian.com)
8 // (C) Ximian, Inc. http://www.ximian.com
12 using System.Collections;
13 using System.Reflection;
14 using System.Runtime.CompilerServices;
16 namespace System.Runtime.Remoting.Messaging {
19 public class MonoMethodMessage : IMethodCallMessage, IMethodReturnMessage, IInternalMessage {
27 byte [] arg_types; /* 1 == IN; 2 == OUT ; 3 = INOUT */
29 public LogicalCallContext ctx;
35 AsyncResult asyncResult;
39 MethodCallDictionary properties;
41 Type[] methodSignature;
46 [MethodImplAttribute(MethodImplOptions.InternalCall)]
47 internal extern void InitMessage (MonoMethod method, object [] out_args);
49 public MonoMethodMessage (MethodBase method, object [] out_args)
52 InitMessage ((MonoMethod)method, out_args);
57 public MonoMethodMessage (Type type, string method_name, object [] in_args)
59 // fixme: consider arg types
60 MethodInfo minfo = type.GetMethod (method_name);
62 InitMessage ((MonoMethod)minfo, null);
64 int len = in_args.Length;
65 for (int i = 0; i < len; i++) {
66 args [i] = in_args [i];
70 public IDictionary Properties {
72 if (properties == null) properties = new MethodCallDictionary (this);
86 public object [] Args {
92 public bool HasVarArgs {
98 public LogicalCallContext LogicalCallContext {
104 public MethodBase MethodBase {
110 public string MethodName {
119 public object MethodSignature {
121 if (methodSignature == null) {
122 ParameterInfo[] parameters = method.GetParameters();
123 methodSignature = new Type[parameters.Length];
124 for (int n=0; n<parameters.Length; n++)
125 methodSignature[n] = parameters[n].ParameterType;
127 return methodSignature;
131 public string TypeName {
136 return method.DeclaringType.AssemblyQualifiedName;
150 public object GetArg (int arg_num)
155 return args [arg_num];
158 public string GetArgName (int arg_num)
163 return names [arg_num];
166 public int InArgCount {
173 foreach (byte t in arg_types) {
174 if ((t & 1) != 0) count++;
181 public object [] InArgs {
183 int i, j, count = InArgCount;
184 object [] inargs = new object [count];
187 foreach (byte t in arg_types) {
189 inargs [j++] = args [i];
197 public object GetInArg (int arg_num)
200 foreach (byte t in arg_types) {
210 public string GetInArgName (int arg_num)
213 foreach (byte t in arg_types) {
223 public Exception Exception {
229 public int OutArgCount {
236 foreach (byte t in arg_types) {
237 if ((t & 2) != 0) count++;
244 public object [] OutArgs {
249 int i, j, count = OutArgCount;
250 object [] outargs = new object [count];
253 foreach (byte t in arg_types) {
255 outargs [j++] = args [i];
263 public object ReturnValue {
269 public object GetOutArg (int arg_num)
272 foreach (byte t in arg_types) {
282 public string GetOutArgName (int arg_num)
285 foreach (byte t in arg_types) {
295 Identity IInternalMessage.TargetIdentity
297 get { return identity; }
298 set { identity = value; }
303 get { return asyncResult != null; }
306 public AsyncResult AsyncResult
308 get { return asyncResult; }