2 // System.Runtime.Remoting.Messaging.MethodCallMessageWrapper.cs
4 // Author: Duncan Mak (duncan@ximian.com)
5 // Lluis Sanchez Gual (lluis@ideary.com)
7 // 2002 (C) Copyright, Ximian, Inc.
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Collections;
35 using System.Reflection;
37 namespace System.Runtime.Remoting.Messaging {
39 [System.Runtime.InteropServices.ComVisible (true)]
40 public class MethodCallMessageWrapper : InternalMessageWrapper, IMethodCallMessage, IMethodMessage, IMessage
44 DictionaryWrapper _properties;
46 public MethodCallMessageWrapper (IMethodCallMessage msg)
49 _args = ((IMethodCallMessage)WrappedMessage).Args;
50 _inArgInfo = new ArgInfo (msg.MethodBase, ArgInfoType.In);
53 public virtual int ArgCount {
54 get { return ((IMethodCallMessage)WrappedMessage).ArgCount; }
57 public virtual object [] Args {
59 set { _args = value; }
62 public virtual bool HasVarArgs {
63 get { return ((IMethodCallMessage)WrappedMessage).HasVarArgs; }
66 public virtual int InArgCount {
67 get { return _inArgInfo.GetInOutArgCount(); }
70 public virtual object[] InArgs {
71 get { return _inArgInfo.GetInOutArgs (_args); }
74 public virtual LogicalCallContext LogicalCallContext {
75 get { return ((IMethodCallMessage)WrappedMessage).LogicalCallContext; }
78 public virtual MethodBase MethodBase {
79 get { return ((IMethodCallMessage)WrappedMessage).MethodBase; }
82 public virtual string MethodName {
83 get { return ((IMethodCallMessage)WrappedMessage).MethodName; }
86 public virtual object MethodSignature {
87 get { return ((IMethodCallMessage)WrappedMessage).MethodSignature; }
90 public virtual IDictionary Properties
94 if (_properties == null) _properties = new DictionaryWrapper(this, WrappedMessage.Properties);
99 public virtual string TypeName {
100 get { return ((IMethodCallMessage)WrappedMessage).TypeName; }
103 public virtual string Uri {
104 get { return ((IMethodCallMessage)WrappedMessage).Uri; }
106 IInternalMessage im = WrappedMessage as IInternalMessage;
107 if (im != null) im.Uri = value;
108 else Properties["__Uri"] = value;
112 public virtual object GetArg (int argNum)
114 return _args[argNum];
117 public virtual string GetArgName (int index)
119 return ((IMethodCallMessage)WrappedMessage).GetArgName (index);
122 public virtual object GetInArg (int argNum)
124 return _args[_inArgInfo.GetInOutArgIndex (argNum)];
127 public virtual string GetInArgName (int index)
129 return _inArgInfo.GetInOutArgName(index);
132 class DictionaryWrapper : MethodCallDictionary
134 IDictionary _wrappedDictionary;
135 static string[] _keys = new string[] {"__Args"};
137 public DictionaryWrapper(IMethodMessage message, IDictionary wrappedDictionary) : base (message)
139 _wrappedDictionary = wrappedDictionary;
143 protected override IDictionary AllocInternalProperties()
145 return _wrappedDictionary;
148 protected override void SetMethodProperty (string key, object value)
150 if (key == "__Args") ((MethodCallMessageWrapper)_message)._args = (object[])value;
151 else base.SetMethodProperty (key, value);
154 protected override object GetMethodProperty (string key)
156 if (key == "__Args") return ((MethodCallMessageWrapper)_message)._args;
157 else return base.GetMethodProperty (key);