// 2002 (C) Copyright, Ximian, Inc.
//
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
using System;
using System.Collections;
using System.Reflection;
namespace System.Runtime.Remoting.Messaging {
[Serializable] [CLSCompliant (false)]
- public class MethodResponse : IMethodReturnMessage, ISerializable, IInternalMessage
+ [System.Runtime.InteropServices.ComVisible (true)]
+ public class MethodResponse : IMethodReturnMessage, ISerializable, IInternalMessage, ISerializationRootObject
{
string _methodName;
string _uri;
protected IDictionary ExternalProperties;
protected IDictionary InternalProperties;
- public MethodResponse (Header[] headers, IMethodCallMessage mcm)
+ public MethodResponse (Header[] h1, IMethodCallMessage mcm)
{
if (mcm != null)
{
_args = mcm.Args;
}
- if (headers != null)
+ if (h1 != null)
{
- foreach (Header header in headers)
+ foreach (Header header in h1)
InitMethodProperty (header.Name, header.Value);
}
}
_exception = null;
_returnValue = returnValue;
- _outArgs = outArgs;
+ _args = outArgs;
}
internal MethodResponse (IMethodCallMessage msg, CADMethodReturnMessage retmsg) {
_exception = retmsg.GetException (args);
_returnValue = retmsg.GetReturnValue (args);
- _outArgs = retmsg.GetArgs (args);
+ _args = retmsg.GetArgs (args);
+ _callContext = retmsg.GetLogicalCallContext (args);
+ if (_callContext == null) _callContext = new LogicalCallContext ();
+
if (retmsg.PropertiesCount > 0)
CADMessageBase.UnmarshalProperties (Properties, retmsg.PropertiesCount, args);
}
case "__MethodSignature": _methodSignature = (Type[]) value; break;
case "__Uri": _uri = (string) value; break;
case "__Return": _returnValue = value; break;
- case "__OutArgs": _outArgs = (object[]) value; break;
+ case "__OutArgs": _args = (object[]) value; break;
case "__fault": _exception = (Exception) value; break;
case "__CallContext": _callContext = (LogicalCallContext) value; break;
default: Properties [key] = value; break;
public bool HasVarArgs {
get {
- return false; // TODO: implement var args
+ return (MethodBase.CallingConvention | CallingConventions.VarArgs) != 0;
}
}
public LogicalCallContext LogicalCallContext {
- get {
+ get {
+ if (_callContext == null)
+ _callContext = new LogicalCallContext ();
return _callContext;
}
}
public MethodBase MethodBase {
get {
- if (null == _methodBase && null != _callMsg)
- _methodBase = _callMsg.MethodBase;
-
+ if (null == _methodBase) {
+ if (_callMsg != null)
+ _methodBase = _callMsg.MethodBase;
+ else if (MethodName != null && TypeName != null)
+ _methodBase = RemotingServices.GetMethodBaseFromMethodMessage (this);
+ }
return _methodBase;
}
}
public int OutArgCount {
get {
- if (null == _outArgs)
- return 0;
-
- return _outArgs.Length;
+ if (_args == null || _args.Length == 0) return 0;
+ if (_inArgInfo == null) _inArgInfo = new ArgInfo (MethodBase, ArgInfoType.Out);
+ return _inArgInfo.GetInOutArgCount ();
}
}
public object[] OutArgs {
get {
- if (null == _outArgs)
- return new object[0];
-
+ if (_outArgs == null && _args != null) {
+ if (_inArgInfo == null) _inArgInfo = new ArgInfo (MethodBase, ArgInfoType.Out);
+ _outArgs = _inArgInfo.GetInOutArgs (_args);
+ }
return _outArgs;
}
}
}
}
+ string IInternalMessage.Uri {
+ get { return Uri; }
+ set { Uri = value; }
+ }
+
public object GetArg (int argNum)
{
- if (null == _outArgs)
+ if (null == _args)
return null;
- return _outArgs [argNum];
+ return _args [argNum];
}
public string GetArgName (int index)
{
- throw new NotSupportedException ();
+ return MethodBase.GetParameters()[index].Name;
}
public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
info.AddValue ("__MethodSignature", _methodSignature);
info.AddValue ("__Uri", _uri);
info.AddValue ("__Return", _returnValue);
- info.AddValue ("__OutArgs", _outArgs);
+ info.AddValue ("__OutArgs", _args);
}
else
info.AddValue ("__fault", _exception);
public object GetOutArg (int argNum)
{
- if (null == _methodBase)
- return null;
-
- return _outArgs [argNum];
+ if (_args == null) return null;
+ if (_inArgInfo == null) _inArgInfo = new ArgInfo (MethodBase, ArgInfoType.Out);
+ return _args[_inArgInfo.GetInOutArgIndex (argNum)];
}
public string GetOutArgName (int index)
}
[MonoTODO]
- public void RootSetObjectData (SerializationInfo info, StreamingContext context)
+ public void RootSetObjectData (SerializationInfo info, StreamingContext ctx)
{
throw new NotImplementedException ();
}
get { return _targetIdentity; }
set { _targetIdentity = value; }
}
+
}
}