| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- //
- // System.Runtime.Remoting.Messaging.MonoMethodMessage.cs
- //
- // Author:
- // Dietmar Maurer ([email protected])
- //
- // (C) Ximian, Inc. http://www.ximian.com
- //
- using System;
- using System.Collections;
- using System.Reflection;
- using System.Runtime.CompilerServices;
- namespace System.Runtime.Remoting.Messaging {
-
- public class MonoMethodMessage : IMethodCallMessage, IMethodReturnMessage {
- MonoMethod method;
- object [] args;
- string [] names;
- byte [] arg_types; /* 1 == IN; 2 == OUT ; 3 = INOUT */
- public LogicalCallContext ctx;
- public object rval;
- public Exception exc;
- string uri;
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern void InitMessage (MonoMethod method, object [] out_args);
- public MonoMethodMessage (MethodBase method, object [] out_args)
- {
- InitMessage ((MonoMethod)method, out_args);
- }
- public MonoMethodMessage (Type type, string method_name, object [] in_args)
- {
- // fixme: consider arg types
- MethodInfo minfo = type.GetMethod (method_name);
-
- InitMessage ((MonoMethod)minfo, null);
- int len = in_args.Length;
- for (int i = 0; i < len; i++) {
- args [i] = in_args [i];
- }
- }
-
- public IDictionary Properties {
- get {
- return null;
- }
- }
- public int ArgCount {
- get {
- return args.Length;
- }
- }
-
- public object [] Args {
- get {
- return args;
- }
- }
-
- public bool HasVarArgs {
- get {
- return false;
- }
- }
- public LogicalCallContext LogicalCallContext {
- get {
- return ctx;
- }
- }
- public MethodBase MethodBase {
- get {
- return method;
- }
- }
- public string MethodName {
- get {
- return method.Name;
- }
- }
- public object MethodSignature {
- get {
- return null;
- }
- }
- public string TypeName {
- get {
- return null;
- }
- }
- public string Uri {
- get {
- return uri;
- }
- set {
- uri = value;
- }
- }
- public object GetArg (int arg_num)
- {
- return args [arg_num];
- }
-
- public string GetArgName (int arg_num)
- {
- return names [arg_num];
- }
- public int InArgCount {
- get {
- int count = 0;
- foreach (byte t in arg_types) {
- if ((t & 1) != 0) count++;
-
- }
- return count;
- }
- }
-
- public object [] InArgs {
- get {
- int i, j, count = InArgCount;
- object [] inargs = new object [count];
- i = j = 0;
- foreach (byte t in arg_types) {
- if ((t & 1) != 0)
- inargs [j++] = args [i];
- i++;
- }
-
- return inargs;
- }
- }
-
- public object GetInArg (int arg_num)
- {
- int i = 0, j = 0;
- foreach (byte t in arg_types) {
- if ((t & 1) != 0) {
- if (j++ == arg_num)
- return args [i];
- }
- i++;
- }
- return null;
- }
-
- public string GetInArgName (int arg_num)
- {
- int i = 0, j = 0;
- foreach (byte t in arg_types) {
- if ((t & 1) != 0) {
- if (j++ == arg_num)
- return names [i];
- }
- i++;
- }
- return null;
- }
- public Exception Exception {
- get {
- return exc;
- }
- }
-
- public int OutArgCount {
- get {
- int count = 0;
- foreach (byte t in arg_types) {
- if ((t & 2) != 0) count++;
-
- }
- return count;
- }
- }
-
- public object [] OutArgs {
- get {
- int i, j, count = OutArgCount;
- object [] outargs = new object [count];
- i = j = 0;
- foreach (byte t in arg_types) {
- if ((t & 2) != 0)
- outargs [j++] = args [i];
- i++;
- }
-
- return outargs;
- }
- }
-
- public object ReturnValue {
- get {
- return rval;
- }
- }
- public object GetOutArg (int arg_num)
- {
- int i = 0, j = 0;
- foreach (byte t in arg_types) {
- if ((t & 2) != 0) {
- if (j++ == arg_num)
- return args [i];
- }
- i++;
- }
- return null;
- }
-
- public string GetOutArgName (int arg_num)
- {
- int i = 0, j = 0;
- foreach (byte t in arg_types) {
- if ((t & 2) != 0) {
- if (j++ == arg_num)
- return names [i];
- }
- i++;
- }
- return null;
- }
- }
- }
|