Merge pull request #1659 from alexanderkyte/stringbuilder-referencesource
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Messaging / ReturnMessage.cs
index e717b471e94a830bd426c8300a1a558dc33475cf..8b1c7be6b6bf37904fdae1f303048ba306bd49ae 100644 (file)
@@ -37,11 +37,11 @@ using System.IO;
 
 namespace System.Runtime.Remoting.Messaging 
 {
+       [System.Runtime.InteropServices.ComVisible (true)]
        public class ReturnMessage : IMethodReturnMessage, IMethodMessage, IMessage, IInternalMessage 
        {
                object[] _outArgs;
                object[] _args;
-               int _outArgsCount;
                LogicalCallContext _callCtx;
                object _returnValue;
                string _uri;
@@ -54,29 +54,30 @@ namespace System.Runtime.Remoting.Messaging
                Identity _targetIdentity;
                ArgInfo _inArgInfo;
 
-               public ReturnMessage (object returnValue, object [] outArgs,
-                              int outArgCount, LogicalCallContext callCtx,
-                              IMethodCallMessage request)
+               public ReturnMessage (object ret, object [] outArgs,
+                              int outArgsCount, LogicalCallContext callCtx,
+                              IMethodCallMessage mcm)
                {
                        // outArgCount tells how many values of outArgs are valid
 
-                       _returnValue = returnValue;
+                       _returnValue = ret;
                        _args = outArgs;
-                       _outArgsCount = outArgCount;
                        _callCtx = callCtx;
-                       if (request != null) {
-                               _uri = request.Uri;
-                               _methodBase = request.MethodBase;
+                       if (mcm != null) {
+                               _uri = mcm.Uri;
+                               _methodBase = mcm.MethodBase;
                        }
-                       if (_args == null) _args = new object [outArgCount];
+                       if (_args == null) _args = new object [outArgsCount];
                }
 
-               public ReturnMessage (Exception exc, IMethodCallMessage request)
+               public ReturnMessage (Exception e, IMethodCallMessage mcm)
                {
-                       _exception = exc;
+                       _exception = e;
                        
-                       if (request != null)
-                               _methodBase = request.MethodBase;
+                       if (mcm != null) {
+                               _methodBase = mcm.MethodBase;
+                               _callCtx = mcm.LogicalCallContext;
+                       }
                        _args = new object[0];  // .NET does this
                }
                
@@ -102,9 +103,8 @@ namespace System.Runtime.Remoting.Messaging
                public LogicalCallContext LogicalCallContext {
                        get {
                                if (_callCtx == null)
-                                       return LogicalCallContext.Empty;
-                               else
-                                       return _callCtx;
+                                       _callCtx = new LogicalCallContext ();
+                               return _callCtx;
                        }
                }
 
@@ -162,14 +162,19 @@ namespace System.Runtime.Remoting.Messaging
                        }
                }
 
-               public object GetArg (int arg_num)
+               string IInternalMessage.Uri {
+                       get { return Uri; }
+                       set { Uri = value; }
+               }
+
+               public object GetArg (int argNum)
                {
-                       return _args [arg_num];
+                       return _args [argNum];
                }
                
-               public string GetArgName (int arg_num)
+               public string GetArgName (int index)
                {
-                       return _methodBase.GetParameters()[arg_num].Name;
+                       return _methodBase.GetParameters()[index].Name;
                }
 
                public Exception Exception {
@@ -202,16 +207,16 @@ namespace System.Runtime.Remoting.Messaging
                        }
                }
 
-               public object GetOutArg (int arg_num)
+               public object GetOutArg (int argNum)
                {
                        if (_inArgInfo == null) _inArgInfo = new ArgInfo (MethodBase, ArgInfoType.Out);
-                       return _args[_inArgInfo.GetInOutArgIndex (arg_num)];
+                       return _args[_inArgInfo.GetInOutArgIndex (argNum)];
                }
 
-               public string GetOutArgName (int arg_num)
+               public string GetOutArgName (int index)
                {
                        if (_inArgInfo == null) _inArgInfo = new ArgInfo (MethodBase, ArgInfoType.Out);
-                       return _inArgInfo.GetInOutArgName(arg_num);
+                       return _inArgInfo.GetInOutArgName (index);
                }
 
                Identity IInternalMessage.TargetIdentity
@@ -220,26 +225,14 @@ namespace System.Runtime.Remoting.Messaging
                        set { _targetIdentity = value; }
                }
 
-               public override string ToString ()
+               bool IInternalMessage.HasProperties ()
                {
-                       string s = TypeName.Split(',')[0] + "." + MethodName + " (";
-                       if (_exception != null)
-                       {
-                               s += "Exception)\n" + _exception;
-                       }
-                       else
-                       {
-                               for (int n=0; n<OutArgs.Length; n++)
-                               {
-                                       if (n>0) s+= ", ";
-                                       if (OutArgs[n] != null) s += OutArgs[n].GetType().Name + " ";
-                                       s += GetOutArgName (n);
-                                       if (OutArgs[n] != null) s += " = {" + OutArgs[n] + "}";
-                                       else s+=" = {null}";
-                               }
-                               s += ")";
-                       }
-                       return s;
+                       return _properties != null;
+               }
+
+               internal bool HasProperties ()
+               {
+                       return _properties != null;
                }
        }
 }