Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MethodReturnMessageWrapper.cs « System.Runtime.Remoting.Messaging « corlib « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7abdc1a4b1ec1298010c1410f1e34c30cbd94af7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//
// System.Runtime.Remoting.Messaging.MethodReturnMessageWrapper.cs
//
// Author: Duncan Mak (duncan@ximian.com)
//         Lluis Sanchez Gual (lluis@ideary.com)
//
// 2002 (C) Copyright, Ximian, Inc.
//

using System;
using System.Collections;
using System.Reflection;
using System.Runtime.Serialization;

namespace System.Runtime.Remoting.Messaging {

	public class MethodReturnMessageWrapper : InternalMessageWrapper, IMethodReturnMessage, IMethodMessage, IMessage
	{
		object[] _args;
		ArgInfo _outArgInfo;
		DictionaryWrapper _properties;
		Exception _exception;
		object _return;

		public MethodReturnMessageWrapper (IMethodReturnMessage msg)
			: base (msg)
		{
			_args = ((IMethodCallMessage)WrappedMessage).Args;
			_exception = msg.Exception;
			_outArgInfo = new ArgInfo (msg.MethodBase, ArgInfoType.Out);
		}

		public virtual int ArgCount {
			get { return ((IMethodReturnMessage)WrappedMessage).ArgCount; }
		}

		public virtual object [] Args 
		{
			get { return _args; }
			set { _args = value; }
		}

		public virtual Exception Exception {
			get { return _exception; }
			set { _exception = value; }
		}
		
		public virtual bool HasVarArgs {
			get { return ((IMethodReturnMessage)WrappedMessage).HasVarArgs; }
		}
		
		public virtual LogicalCallContext LogicalCallContext {
			get { return ((IMethodReturnMessage)WrappedMessage).LogicalCallContext; }
		}
		
		public virtual MethodBase MethodBase {
			get { return ((IMethodReturnMessage)WrappedMessage).MethodBase; }
		}

		public virtual string MethodName {
			get { return ((IMethodReturnMessage)WrappedMessage).MethodName; }
		}

		public virtual object MethodSignature {
			get { return ((IMethodReturnMessage)WrappedMessage).MethodSignature; }
		}

		public virtual int OutArgCount {
			get { return _outArgInfo.GetInOutArgCount(); }
		}

		public virtual object[] OutArgs {
			get { return _outArgInfo.GetInOutArgs (_args); }
		}

		public virtual IDictionary Properties 
		{
			get { 
				if (_properties == null) _properties = new DictionaryWrapper(this, WrappedMessage.Properties);
				return _properties; 
			}
		}

		public virtual object ReturnValue {
			get { return _return; }
			set { _return = value; }
		}

		public virtual string TypeName {
			get { return ((IMethodReturnMessage)WrappedMessage).TypeName; }
		}

		public virtual string Uri 
		{
			get { return ((IMethodReturnMessage)WrappedMessage).Uri; }
			set { Properties["__Uri"] = value; }
		}

		public virtual object GetArg (int argNum)
		{
			return _args[argNum];
		}

		public virtual string GetArgName (int index)
		{
			return ((IMethodReturnMessage)WrappedMessage).GetArgName(index);
		}

		[MonoTODO]
		public void GetObjectData (SerializationInfo info, StreamingContext context)
		{
			throw new NotImplementedException ();
		} 

		public virtual object GetOutArg (int argNum)
		{
			return _args [_outArgInfo.GetInOutArgIndex (argNum)];
		}

		public virtual string GetOutArgName (int index)
		{
			return _outArgInfo.GetInOutArgName(index);
		}

		[MonoTODO]
		public virtual object HeaderHandler (Header[] h)
		{
			throw new NotImplementedException ();
		}

		[MonoTODO]
		public void RootSetObjectData (SerializationInfo info, StreamingContext context)
		{
			throw new NotImplementedException ();
		} 

		class DictionaryWrapper : MethodReturnDictionary
		{
			IDictionary _wrappedDictionary;
			static string[] _keys = new string[] {"__Args", "__Return"};

			public DictionaryWrapper(IMethodReturnMessage message, IDictionary wrappedDictionary) : base (message)
			{
				_wrappedDictionary = wrappedDictionary;
				MethodKeys = _keys;
			}

			protected override IDictionary AllocInternalProperties()
			{
				return _wrappedDictionary;
			}

			protected override void SetMethodProperty (string key, object value)
			{
				if (key == "__Args") ((MethodReturnMessageWrapper)_message)._args = (object[])value;
				else if (key == "__Return") ((MethodReturnMessageWrapper)_message)._return = value;
				else base.SetMethodProperty (key, value);
			}

			protected override object GetMethodProperty (string key)
			{
				if (key == "__Args") return ((MethodReturnMessageWrapper)_message)._args;
				else if (key == "__Return") return ((MethodReturnMessageWrapper)_message)._return;
				else return base.GetMethodProperty (key);
			}
		}
	}
}