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 public class MethodCallMessageWrapper : InternalMessageWrapper, IMethodCallMessage, IMethodMessage, IMessage
43 DictionaryWrapper _properties;
45 public MethodCallMessageWrapper (IMethodCallMessage msg)
48 _args = ((IMethodCallMessage)WrappedMessage).Args;
49 _inArgInfo = new ArgInfo (msg.MethodBase, ArgInfoType.In);
52 public virtual int ArgCount {
53 get { return ((IMethodCallMessage)WrappedMessage).ArgCount; }
56 public virtual object [] Args {
58 set { _args = value; }
61 public virtual bool HasVarArgs {
62 get { return ((IMethodCallMessage)WrappedMessage).HasVarArgs; }
65 public int InArgCount {
66 get { return _inArgInfo.GetInOutArgCount(); }
69 public object[] InArgs {
70 get { return _inArgInfo.GetInOutArgs (_args); }
73 public virtual LogicalCallContext LogicalCallContext {
74 get { return ((IMethodCallMessage)WrappedMessage).LogicalCallContext; }
77 public virtual MethodBase MethodBase {
78 get { return ((IMethodCallMessage)WrappedMessage).MethodBase; }
81 public virtual string MethodName {
82 get { return ((IMethodCallMessage)WrappedMessage).MethodName; }
85 public virtual object MethodSignature {
86 get { return ((IMethodCallMessage)WrappedMessage).MethodSignature; }
89 public virtual IDictionary Properties
93 if (_properties == null) _properties = new DictionaryWrapper(this, WrappedMessage.Properties);
98 public virtual string TypeName {
99 get { return ((IMethodCallMessage)WrappedMessage).TypeName; }
102 public virtual string Uri {
103 get { return ((IMethodCallMessage)WrappedMessage).Uri; }
105 IInternalMessage im = WrappedMessage as IInternalMessage;
106 if (im != null) im.Uri = value;
107 else Properties["__Uri"] = value;
111 public virtual object GetArg (int argNum)
113 return _args[argNum];
116 public virtual string GetArgName (int index)
118 return ((IMethodCallMessage)WrappedMessage).GetArgName (index);
121 public object GetInArg (int argNum)
123 return _args[_inArgInfo.GetInOutArgIndex (argNum)];
126 public string GetInArgName (int index)
128 return _inArgInfo.GetInOutArgName(index);
131 class DictionaryWrapper : MethodCallDictionary
\r
133 IDictionary _wrappedDictionary;
\r
134 static string[] _keys = new string[] {"__Args"};
\r
136 public DictionaryWrapper(IMethodMessage message, IDictionary wrappedDictionary) : base (message)
\r
138 _wrappedDictionary = wrappedDictionary;
\r
139 MethodKeys = _keys;
\r
142 protected override IDictionary AllocInternalProperties()
\r
144 return _wrappedDictionary;
\r
147 protected override void SetMethodProperty (string key, object value)
149 if (key == "__Args") ((MethodCallMessageWrapper)_message)._args = (object[])value;
150 else base.SetMethodProperty (key, value);
153 protected override object GetMethodProperty (string key)
155 if (key == "__Args") return ((MethodCallMessageWrapper)_message)._args;
156 else return base.GetMethodProperty (key);