// 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 MethodCall : IMethodCallMessage, IMethodMessage, IMessage, ISerializable, IInternalMessage
+ public class MethodCall : IMethodCallMessage, IMethodMessage, IMessage, ISerializable, IInternalMessage, ISerializationRootObject
{
string _uri;
string _typeName;
foreach (SerializationEntry entry in info)
InitMethodProperty ((string)entry.Name, entry.Value);
-
- ResolveMethod ();
}
internal MethodCall (CADMethodCallMessage msg)
{
- _typeName = msg.TypeName;
- _uri = msg.Uri;
- _methodName = msg.MethodName;
+ _uri = string.Copy (msg.Uri);
// Get unmarshalled arguments
ArrayList args = msg.GetArguments ();
_args = msg.GetArgs (args);
- _methodSignature = (Type []) msg.GetMethodSignature (args);
+ _callContext = msg.GetLogicalCallContext (args);
+ if (_callContext == null)
+ _callContext = new LogicalCallContext ();
- ResolveMethod ();
+ _methodBase = MethodBase.GetMethodFromHandle (msg.MethodHandle);
Init();
if (msg.PropertiesCount > 0)
CopyFrom ((IMethodMessage) msg);
else
{
- IDictionary dic = msg.Properties;
foreach (DictionaryEntry entry in msg.Properties)
InitMethodProperty ((String) entry.Key, entry.Value);
Init();
get { return _args; }
}
- [MonoTODO]
public bool HasVarArgs {
- get { throw new NotImplementedException (); }
+ get { return (MethodBase.CallingConvention | CallingConventions.VarArgs) != 0; }
}
public int InArgCount
}
public string MethodName {
- get { return _methodName; }
+ get {
+ // lazily fill in _methodName from _methodBase
+ if (_methodName == null)
+ _methodName = _methodBase.Name;
+ return _methodName;
+ }
}
public object MethodSignature {
public string TypeName
{
- get { return _typeName; }
+ get {
+ // lazily fill in _typeName from _methodBase
+ if (_typeName == null)
+ _typeName = _methodBase.DeclaringType.AssemblyQualifiedName;
+ return _typeName;
+ }
}
public string Uri {
if (_uri != null)
{
Type type = RemotingServices.GetServerTypeForUri (_uri);
+ if (type == null) throw new RemotingException ("Requested service not found. No receiver for uri " + _uri);
- if (CanCastTo (_typeName, type))
- {
- BindingFlags bflags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
- if (_methodSignature == null) _methodBase = type.GetMethod (_methodName, bflags);
- else _methodBase = type.GetMethod (_methodName, bflags, null, _methodSignature, null);
+ if (CanCastTo (_typeName, type)) {
+ _methodBase = RemotingServices.GetMethodBaseFromName (type, _methodName, _methodSignature);
return;
}
else
_methodBase = RemotingServices.GetMethodBaseFromMethodMessage (this);
}
- public bool CanCastTo (string clientType, Type serverType)
+ bool CanCastTo (string clientType, Type serverType)
{
- int i = clientType.IndexOf(",");
+ int i = clientType.IndexOf(',');
if (i != -1) clientType = clientType.Substring (0,i).Trim();
if (clientType == serverType.FullName) return true;