* IInternalMessage.cs: Added. Provides some useful methods for method messages.
authorLluis Sanchez <lluis@novell.com>
Wed, 19 Feb 2003 12:38:28 +0000 (12:38 -0000)
committerLluis Sanchez <lluis@novell.com>
Wed, 19 Feb 2003 12:38:28 +0000 (12:38 -0000)
* ServerContextTerminatorSink.cs: Added support for construction messages.
* MethodCall.cs: Implemented serialization support. Added support for IInternalMessage.
* MethodDictionary.cs: Added support for IInternalMessage.
* MethodResponse.cs: Added serialization support. Added support for IInternalMessage.
* MonoMethodMessage.cs: Added support for IInternalMessage.
* ReturnMessage.cs: Added support for IInternalMessage.
* ClientContextTerminatorSink.cs: Added.
* ConstructionCall.cs: Added.
* ConstructionCallDictionary.cs: Added.
* ConstructionResponse.cs: Added.
* EnvoyTerminatorSink.cs: Added.

svn path=/trunk/mcs/; revision=11726

13 files changed:
mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog
mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs [new file with mode: 0644]
mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs [new file with mode: 0644]
mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCallDictionary.cs [new file with mode: 0644]
mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs [new file with mode: 0644]
mcs/class/corlib/System.Runtime.Remoting.Messaging/EnvoyTerminatorSink.cs [new file with mode: 0644]
mcs/class/corlib/System.Runtime.Remoting.Messaging/IInternalMessage.cs [new file with mode: 0644]
mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodCall.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodDictionary.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/MethodResponse.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/ReturnMessage.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/ServerContextTerminatorSink.cs

index dfe3f59f44353ed499985876ac1417d72aae8f05..e091181a8c9333222db5f7017c90bd64ac19e5c9 100644 (file)
@@ -1,3 +1,18 @@
+2003-02-18  Lluis Sanchez Gual <lluis@ideary.com>
+
+       * IInternalMessage.cs: Added. Provides some useful methods for method messages.
+       * ServerContextTerminatorSink.cs: Added support for construction messages.
+       * MethodCall.cs: Implemented serialization support. Added support for IInternalMessage.
+       * MethodDictionary.cs: Added support for IInternalMessage.
+       * MethodResponse.cs: Added serialization support. Added support for IInternalMessage.
+       * MonoMethodMessage.cs: Added support for IInternalMessage.
+       * ReturnMessage.cs: Added support for IInternalMessage.
+       * ClientContextTerminatorSink.cs: Added.
+       * ConstructionCall.cs: Added.
+       * ConstructionCallDictionary.cs: Added.
+       * ConstructionResponse.cs: Added.
+       * EnvoyTerminatorSink.cs: Added.
+       
 2003-02-07  Patrik Torstensson
 
        * CADMessages.cs: Disable smuggeling of objects cross domain, still issues casing remoting
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ClientContextTerminatorSink.cs
new file mode 100644 (file)
index 0000000..0e0d87b
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// System.Runtime.Remoting.Messaging.ClientContextTerminatorSink.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ideary.com)
+//
+// (C) 2003, Lluis Sanchez Gual
+//\r
+\r
+using System;\r
+using System.Runtime.Remoting;\r
+\r
+namespace System.Runtime.Remoting.Messaging\r
+{\r
+       public class ClientContextTerminatorSink: IMessageSink\r
+       {\r
+               public ClientContextTerminatorSink()\r
+               {\r
+               }\r
+\r
+               public IMessage SyncProcessMessage (IMessage msg)
+               {
+                       Identity identity = RemotingServices.GetMessageTargetIdentity (msg);
+                       return identity.ChannelSink.SyncProcessMessage (msg);
+               }
+
+               public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
+               {
+                       Identity identity = RemotingServices.GetMessageTargetIdentity (msg);
+                       return identity.ChannelSink.AsyncProcessMessage (msg, replySink);
+               }
+
+               public IMessageSink NextSink 
+               { 
+                       get { return null; }
+               }       \r
+       }\r
+}\r
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCall.cs
new file mode 100644 (file)
index 0000000..f9e19b3
--- /dev/null
@@ -0,0 +1,108 @@
+//
+// System.Runtime.Remoting.Messaging.ConstructionCall.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ideary.com)
+//
+// (C) 2003, Lluis Sanchez Gual
+//\r
+\r
+using System;\r
+using System.Threading;\r
+using System.Collections;\r
+using System.Runtime.Remoting.Activation;\r
+using System.Runtime.Serialization;\r
+using System.Runtime.Remoting.Contexts;\r
+\r
+namespace System.Runtime.Remoting.Messaging\r
+{\r
+       [Serializable] [CLSCompliant (false)]
+       public class ConstructionCall: MethodCall, IConstructionCallMessage\r
+       {\r
+               IActivator _activator;\r
+               object[] _activationAttributes;\r
+               IList _contextProperties;\r
+               Type _activationType;\r
+               string _activationTypeName;\r
+\r
+               public ConstructionCall(IMessage msg): base (msg)\r
+               {\r
+                       _activationTypeName = TypeName;\r
+\r
+/*                     object[] attribs = ActivationType.GetCustomAttributes (typeof (IContextProperty), true);\r
+\r
+                       if (attribs.Length > 0)\r
+                               _contextProperties = new ArrayList (attribs);\r
+*/\r
+                       _activationAttributes = null;   // FIXME: put something here\r
+               }\r
+\r
+               public ConstructionCall (Header[] headers): base (headers)\r
+               {\r
+               }\r
+\r
+               internal ConstructionCall (SerializationInfo info, StreamingContext context): base (info, context)
+               {
+               }
+\r
+               internal override void InitDictionary()\r
+               {\r
+                       ConstructionCallDictionary props = new ConstructionCallDictionary (this);\r
+                       ExternalProperties = props;
+                       InternalProperties = props.GetInternalProperties();\r
+               }\r
+\r
+               public Type ActivationType \r
+               {
+                       get 
+                       { 
+                               if (_activationType == null) _activationType = Type.GetType (_activationTypeName);
+                               return _activationType; 
+                       }
+               }
+
+               public string ActivationTypeName \r
+               {
+                       get { return _activationTypeName; }
+               }
+
+               public IActivator Activator \r
+               {
+                       get { return _activator; }
+                       set { _activator = value; }
+               }
+
+               public object [] CallSiteActivationAttributes \r
+               {
+                       get { return _activationAttributes; }
+               }
+
+               public IList ContextProperties \r
+               {
+                       get { return _contextProperties; }
+               }\r
+\r
+               internal override void InitMethodProperty(string key, object value)
+               {
+                       switch (key)
+                       {
+                               case "__Activator" : _activator = (IActivator) value; return;
+                               case "__CallSiteActivationAttributes" : _activationAttributes = (object[]) value; return;
+                               case "__ActivationType" : _activationType = (Type) value; return;
+                               case "__ContextProperties" : _contextProperties = (IList) value; return;
+                               case "__ActivationTypeName" : _activationTypeName = (string) value; return;
+                               default: base.InitMethodProperty (key, value); return;
+                       }
+               }
+
+               public override void GetObjectData (SerializationInfo info, StreamingContext context)
+               {
+                       base.GetObjectData (info, context);
+
+                       info.AddValue ("__Activator", _activator);
+                       info.AddValue ("__CallSiteActivationAttributes", _activationAttributes);
+                       info.AddValue ("__ActivationType", null);
+                       info.AddValue ("__ContextProperties", _contextProperties);
+                       info.AddValue ("__ActivationTypeName", _activationTypeName);
+               } \r
+       }\r
+}\r
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCallDictionary.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionCallDictionary.cs
new file mode 100644 (file)
index 0000000..affbae0
--- /dev/null
@@ -0,0 +1,51 @@
+//
+// System.Runtime.Remoting.Messaging.ConstructionCallDictionary.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ideary.com)
+//
+// (C) 2003, Lluis Sanchez Gual
+//\r
+\r
+using System;\r
+using System.Runtime.Remoting.Activation;\r
+\r
+namespace System.Runtime.Remoting.Messaging\r
+{\r
+       class ConstructionCallDictionary : MethodDictionary\r
+       {\r
+               public static string[] InternalKeys = new string[] {"__Uri", "__MethodName", "__TypeName", "__MethodSignature", "__Args", "__CallContext", "__CallSiteActivationAttributes", "__ActivationType", "__ContextProperties", "__Activator", "__ActivationTypeName"};\r
+\r
+               public ConstructionCallDictionary(IConstructionCallMessage message) : base (message) \r
+               { \r
+                       MethodKeys = InternalKeys;\r
+               }\r
+
+               protected override object GetMethodProperty (string key)
+               {
+                       switch (key)
+                       {
+                               case "__Activator" : return ((IConstructionCallMessage)_message).Activator;
+                               case "__CallSiteActivationAttributes" : return ((IConstructionCallMessage)_message).CallSiteActivationAttributes;
+                               case "__ActivationType" : return ((IConstructionCallMessage)_message).ActivationType;
+                               case "__ContextProperties" : return ((IConstructionCallMessage)_message).ContextProperties;
+                               case "__ActivationTypeName" : return ((IConstructionCallMessage)_message).ActivationTypeName;
+                               default : return base.GetMethodProperty (key);
+                       }
+               }
+                       
+               protected override void SetMethodProperty (string key, object value)
+               {
+                       switch (key)
+                       {
+                               case "__Activator": ((IConstructionCallMessage)_message).Activator = (IActivator) value; break;
+
+                               case "__CallSiteActivationAttributes":
+                               case "__ActivationType": 
+                               case "__ContextProperties": 
+                               case "__ActivationTypeName": throw new ArgumentException ("key was invalid");
+
+                               default: base.SetMethodProperty (key, value); break;
+                       }
+               }
+       }\r
+}\r
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/ConstructionResponse.cs
new file mode 100644 (file)
index 0000000..9a4a8eb
--- /dev/null
@@ -0,0 +1,27 @@
+//
+// System.Runtime.Remoting.Messaging.ConstructionResponse.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ideary.com)
+//
+// (C) 2003, Lluis Sanchez Gual
+//\r
+\r
+using System;\r
+using System.Runtime.Remoting.Activation;\r
+using System.Runtime.Serialization;
+\r
+namespace System.Runtime.Remoting.Messaging\r
+{\r
+       [Serializable] [CLSCompliant (false)]
+       public class ConstructionResponse: MethodResponse, IConstructionReturnMessage\r
+       {\r
+               public ConstructionResponse(object resultObject, LogicalCallContext callCtx, IMethodCallMessage msg)\r
+                       : base (resultObject, null, callCtx, msg)\r
+               {\r
+               }\r
+\r
+               internal ConstructionResponse (SerializationInfo info, StreamingContext context): base (info, context)
+               {
+               }
+       }\r
+}\r
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/EnvoyTerminatorSink.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/EnvoyTerminatorSink.cs
new file mode 100644 (file)
index 0000000..4e20481
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// System.Runtime.Remoting.Messaging.EnvoyTerminatorSink.cs
+//
+// Author: Lluis Sanchez Gual (lluis@ideary.com)
+//
+// (C) 2003, Lluis Sanchez Gual
+//\r
+\r
+using System;\r
+using System.Threading;\r
+\r
+namespace System.Runtime.Remoting.Messaging\r
+{\r
+       internal class EnvoyTerminatorSink: IMessageSink\r
+       {\r
+               public static EnvoyTerminatorSink Instance = new EnvoyTerminatorSink();\r
+\r
+               public IMessage SyncProcessMessage (IMessage msg)
+               {
+//                     FIXME: restore when Thread.CurrentContext workds
+//                     return Thread.CurrentContext.GetClientContextSinkChain ().SyncProcessMessage (msg);
+                       return System.Runtime.Remoting.Contexts.Context.DefaultContext.GetClientContextSinkChain ().SyncProcessMessage (msg);
+               }
+
+               public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
+               {
+                       return Thread.CurrentContext.GetClientContextSinkChain ().AsyncProcessMessage (msg, replySink);
+               }
+
+               public IMessageSink NextSink 
+               { 
+                       get { return null; }
+               }\r
+       }\r
+}\r
diff --git a/mcs/class/corlib/System.Runtime.Remoting.Messaging/IInternalMessage.cs b/mcs/class/corlib/System.Runtime.Remoting.Messaging/IInternalMessage.cs
new file mode 100644 (file)
index 0000000..2c19a4e
--- /dev/null
@@ -0,0 +1,11 @@
+using System;\r
+using System.Runtime.Remoting;\r
+\r
+namespace System.Runtime.Remoting.Messaging\r
+{\r
+       internal interface IInternalMessage\r
+       {\r
+               Identity TargetIdentity { get; set; }\r
+               string Uri { get; set; }\r
+       }\r
+}\r
index 630117f6e9d2f5537564d7e9664a7ec53b78296e..bd218a285ee732ed797ad7a5459efd507421dcad 100644 (file)
@@ -15,7 +15,7 @@ using System.Runtime.Serialization;
 namespace System.Runtime.Remoting.Messaging {
 
        [Serializable] [CLSCompliant (false)]
-       public class MethodCall : IMethodCallMessage, IMethodMessage, IMessage, ISerializable
+       public class MethodCall : IMethodCallMessage, IMethodMessage, IMessage, ISerializable, IInternalMessage
        {
                string _uri;
                string _typeName;
@@ -25,7 +25,10 @@ namespace System.Runtime.Remoting.Messaging {
                MethodBase _methodBase;
                LogicalCallContext _callContext;
                ArgInfo _inArgInfo;
-               InternalDictionary _properties;
+               Identity _targetIdentity;
+
+               protected IDictionary ExternalProperties;
+               protected IDictionary InternalProperties;
 
                public MethodCall (Header [] headers)
                {
@@ -34,23 +37,23 @@ namespace System.Runtime.Remoting.Messaging {
                        if (headers == null || headers.Length == 0) return;
 
                        foreach (Header header in headers)
-                       {
-                               switch (header.Name)
-                               {
-                                       case "__TypeName" : _typeName = (string)header.Value; break;
-                                       case "__MethodName" : _methodName = (string)header.Value; break;
-                                       case "__MethodSignature" : _methodSignature = (Type[])header.Value; break;
-                                       case "__Args" : _args = (object[])header.Value; break;
-                                       case "__CallContext" : _callContext = (LogicalCallContext)header.Value; break;
-                                       default: _properties [header.Name] = header.Value; break;
-                               }
-                       }
+                               InitMethodProperty (header.Name, header.Value);
 
                        ResolveMethod ();
+               }
+
+               internal MethodCall (SerializationInfo info, StreamingContext context)
+               {
                        Init();
+
+                       foreach (SerializationEntry entry in info)
+                               InitMethodProperty ((string)entry.Name, entry.Value);
+
+                       ResolveMethod ();
                }
 
-               internal MethodCall (CADMethodCallMessage msg) {
+               internal MethodCall (CADMethodCallMessage msg) 
+               {
                        _typeName = msg.TypeName;
                        _uri = msg.Uri;
                        _methodName = msg.MethodName;
@@ -68,15 +71,60 @@ namespace System.Runtime.Remoting.Messaging {
                                CADMessageBase.UnmarshalProperties (Properties, msg.PropertiesCount, args);
                }
 
-               [MonoTODO]
                public MethodCall (IMessage msg)
                {
+                       IMethodMessage call = (IMethodMessage) msg;
+                       _uri = call.Uri;
+                       _typeName = call.TypeName;
+                       _methodName = call.MethodName;
+                       _args = call.Args;
+                       _methodSignature = (Type[]) call.MethodSignature;
+                       _methodBase = call.MethodBase;
+                       _callContext = call.LogicalCallContext;
+
                        Init();
-                       throw new NotImplementedException ();
+                       
                }
 
-               protected IDictionary ExternalProperties;
-               protected IDictionary InternalProperties;
+               public MethodCall (string uri, string typeName, string methodName, object[] args)
+               {
+                       _uri = uri;
+                       _typeName = typeName;
+                       _methodName = methodName;
+                       _args = args;
+
+                       Init();
+                       ResolveMethod();
+               }
+               
+               internal virtual void InitMethodProperty(string key, object value)
+               {
+                       switch (key)
+                       {
+                               case "__TypeName" : _typeName = (string) value; return;
+                               case "__MethodName" : _methodName = (string) value; return;
+                               case "__MethodSignature" : _methodSignature = (Type[]) value; return;
+                               case "__Args" : _args = (object[]) value; return;
+                               case "__CallContext" : _callContext = (LogicalCallContext) value; return;
+                               case "__Uri" : _uri = (string) value; return;
+                               default: Properties[key] = value; return;
+                       }
+               }
+
+               public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
+               {
+                       info.AddValue ("__TypeName", _typeName);
+                       info.AddValue ("__MethodName", _methodName);
+                       info.AddValue ("__MethodSignature", _methodSignature);
+                       info.AddValue ("__Args", _args);
+                       info.AddValue ("__CallContext", _callContext);
+                       info.AddValue ("__Uri", _uri);
+
+                       if (InternalProperties != null) {
+                               foreach (DictionaryEntry entry in InternalProperties)
+                                       info.AddValue ((string) entry.Key, entry.Value);
+                       }
+               } 
 
                public int ArgCount {
                        get { return _args.Length; }
@@ -135,10 +183,22 @@ namespace System.Runtime.Remoting.Messaging {
                }
 
                public virtual IDictionary Properties {
-                       get { return _properties; }
+                       get 
+                       { 
+                               if (ExternalProperties == null) InitDictionary ();
+                               return ExternalProperties; 
+                       }
+               }
+
+               internal virtual void InitDictionary()
+               {
+                       MethodCallDictionary props = new MethodCallDictionary (this);
+                       ExternalProperties = props;
+                       InternalProperties = props.GetInternalProperties();
                }
 
-               public string TypeName {
+               public string TypeName 
+               {
                        get { return _typeName; }
                }
 
@@ -169,12 +229,6 @@ namespace System.Runtime.Remoting.Messaging {
                        return _inArgInfo.GetInOutArgName(index);
                }
 
-               [MonoTODO]
-               public void GetObjectData (SerializationInfo info, StreamingContext context)
-               {
-                       throw new NotImplementedException ();
-               } 
-
                [MonoTODO]
                public virtual object HeaderHandler (Header[] h)
                {
@@ -183,9 +237,6 @@ namespace System.Runtime.Remoting.Messaging {
 
                public virtual void Init ()
                {
-                       _properties = new InternalDictionary (this);
-                       ExternalProperties = _properties;
-                       InternalProperties = _properties.GetInternalProperties();
                }
 
                public void ResolveMethod ()
@@ -199,15 +250,10 @@ namespace System.Runtime.Remoting.Messaging {
                        throw new NotImplementedException ();
                }
 
-               class InternalDictionary : MethodCallDictionary\r
-               {\r
-                       public InternalDictionary(MethodCall message) : base (message) { }\r
-
-                       protected override void SetMethodProperty (string key, object value)
-                       {
-                               if (key == "__Uri") ((MethodCall)_message).Uri = (string)value;
-                               else base.SetMethodProperty (key, value);
-                       }
+               Identity IInternalMessage.TargetIdentity
+               {
+                       get { return _targetIdentity; }
+                       set { _targetIdentity = value; }
                }
        }
 }
index 2d8f7c6b49e0622182330bb01920b4fbd22a850a..edd145adeeaa32b091c8e5354462a30a23d5a11b 100644 (file)
@@ -5,89 +5,89 @@
 //
 // 2003 (C) Lluis Sanchez Gual
 //
-\r
-using System;\r
-using System.Collections;\r
-\r
-namespace System.Runtime.Remoting.Messaging\r
-{\r
-       [Serializable]\r
-       internal class MethodDictionary : IDictionary\r
-       {\r
-               IDictionary _internalProperties = null;\r
-               protected IMethodMessage _message;\r
-               string[] _methodKeys;\r
-               bool _ownProperties = false;\r
-\r
-               public MethodDictionary (IMethodMessage message)\r
-               {\r
-                       _message = message;\r
-               }\r
-\r
-               internal bool HasInternalProperties \r
-               {\r
-                       get \r
-                       {\r
-                               if (null != _internalProperties)\r
-                               {\r
-                                       // MethodCallMessageWrapper uses a nested MethodDictionary\r
-                                       if (_internalProperties is MethodDictionary)\r
-                                               return ((MethodDictionary)_internalProperties).HasInternalProperties;\r
-                                       else \r
-                                               return _internalProperties.Count > 0;\r
-                               }\r
-                               return false;\r
-                       }\r
-               }\r
-\r
-               internal IDictionary InternalProperties\r
-               {\r
-                       get \r
-                       {\r
-                               if (null != _internalProperties)\r
-                               {\r
-                                       if (_internalProperties is MethodDictionary)\r
-                                               return ((MethodDictionary)_internalProperties).InternalProperties;\r
-                               }\r
-                               return _internalProperties;\r
-                       }\r
-               }\r
-\r
-               public string[] MethodKeys\r
-               {\r
-                       get { return _methodKeys; }\r
-                       set { _methodKeys = value; }\r
-               }\r
-\r
-               protected virtual IDictionary AllocInternalProperties()\r
-               {\r
-                       _ownProperties = true;\r
-                       return new Hashtable();\r
-               }\r
-\r
-               public IDictionary GetInternalProperties()\r
-               {\r
-                       if (_internalProperties == null) _internalProperties = AllocInternalProperties();\r
-                       return _internalProperties;\r
-               }\r
-\r
-               private bool IsOverridenKey (string key)\r
-               {\r
-                       // Small optimization. If the internal properties have been\r
-                       // created by this dictionary, then it can be assured that it does\r
-                       // not contain values for overriden keys.\r
-                       if (_ownProperties) return false;\r
-\r
-                       foreach (string mkey in _methodKeys)\r
-                               if (key == mkey) return true;\r
-                       return false;\r
-               }\r
-\r
-               public MethodDictionary(string[] keys)\r
-               {\r
-                       _methodKeys = keys;\r
-               }\r
-\r
+
+using System;
+using System.Collections;
+
+namespace System.Runtime.Remoting.Messaging
+{
+       [Serializable]
+       internal class MethodDictionary : IDictionary
+       {
+               IDictionary _internalProperties = null;
+               protected IMethodMessage _message;
+               string[] _methodKeys;
+               bool _ownProperties = false;
+
+               public MethodDictionary (IMethodMessage message)
+               {
+                       _message = message;
+               }
+
+               internal bool HasInternalProperties 
+               {
+                       get 
+                       {
+                               if (null != _internalProperties)
+                               {
+                                       // MethodCallMessageWrapper uses a nested MethodDictionary
+                                       if (_internalProperties is MethodDictionary)
+                                               return ((MethodDictionary)_internalProperties).HasInternalProperties;
+                                       else 
+                                               return _internalProperties.Count > 0;
+                               }
+                               return false;
+                       }
+               }
+
+               internal IDictionary InternalProperties
+               {
+                       get 
+                       {
+                               if (null != _internalProperties)
+                               {
+                                       if (_internalProperties is MethodDictionary)
+                                               return ((MethodDictionary)_internalProperties).InternalProperties;
+                               }
+                               return _internalProperties;
+                       }
+               }
+
+               public string[] MethodKeys
+               {
+                       get { return _methodKeys; }
+                       set { _methodKeys = value; }
+               }
+
+               protected virtual IDictionary AllocInternalProperties()
+               {
+                       _ownProperties = true;
+                       return new Hashtable();
+               }
+
+               public IDictionary GetInternalProperties()
+               {
+                       if (_internalProperties == null) _internalProperties = AllocInternalProperties();
+                       return _internalProperties;
+               }
+
+               private bool IsOverridenKey (string key)
+               {
+                       // Small optimization. If the internal properties have been
+                       // created by this dictionary, then it can be assured that it does
+                       // not contain values for overriden keys.
+                       if (_ownProperties) return false;
+
+                       foreach (string mkey in _methodKeys)
+                               if (key == mkey) return true;
+                       return false;
+               }
+
+               public MethodDictionary(string[] keys)
+               {
+                       _methodKeys = keys;
+               }
+
                public bool IsFixedSize 
                { 
                        get { return false; } 
@@ -140,12 +140,13 @@ namespace System.Runtime.Remoting.Messaging
                        {
                                case "__CallContext": // Ignore?
                                case "__OutArgs":
-                               case "__Return": break;
+                               case "__Return": return;
 
                                case "__MethodName" : 
                                case "__TypeName" : 
                                case "__MethodSignature" : 
                                case "__Args" : throw new ArgumentException ("key was invalid");
+                               case "__Uri": ((IInternalMessage)_message).Uri = (string) value; return;
                        }
                }
 
@@ -210,15 +211,15 @@ namespace System.Runtime.Remoting.Messaging
                        else return false;
                }
 
-               public void Remove (object key)\r
-               {\r
+               public void Remove (object key)
+               {
                        string keyStr = (string)key;
                        for (int n=0; n<_methodKeys.Length; n++)
                                if (_methodKeys[n] == keyStr) throw new ArgumentException ("key was invalid");
-\r
+
                        if (_internalProperties != null) _internalProperties.Remove (key);
-               }\r
-\r
+               }
+
                public int Count 
                { 
                        get 
@@ -242,18 +243,17 @@ namespace System.Runtime.Remoting.Messaging
                {
                        Values.CopyTo (array, index);
                }
-\r
+
                IEnumerator IEnumerable.GetEnumerator()
                {
                        return new DictionaryEnumerator (this);
                }
-\r
+
                public IDictionaryEnumerator GetEnumerator ()
                {
                        return new DictionaryEnumerator (this);
                }
 
-
                // Dictionary enumerator
 
                class DictionaryEnumerator : IDictionaryEnumerator
@@ -293,7 +293,7 @@ namespace System.Runtime.Remoting.Messaging
                                return false;
                        }
 
-                       public void Reset()\r
+                       public void Reset()
                        {
                                _posMethod = -1;
                                _hashtableEnum.Reset();
@@ -323,5 +323,5 @@ namespace System.Runtime.Remoting.Messaging
                        }
                }
 
-       }\r
-}\r
+       }
+}
index 15910fc36bef246c0bec4fb98980887f7d8f4f5b..bb871d82e22032b11b37fa29f20d58862d693ab6 100644 (file)
@@ -16,7 +16,7 @@ using System.Runtime.Serialization;
 namespace System.Runtime.Remoting.Messaging {
 
        [Serializable] [CLSCompliant (false)]
-       public class MethodResponse : IMethodReturnMessage, ISerializable
+       public class MethodResponse : IMethodReturnMessage, ISerializable, IInternalMessage
        {
                string _methodName;
                string _uri;
@@ -27,16 +27,31 @@ namespace System.Runtime.Remoting.Messaging {
                Exception _exception;
                Type [] _methodSignature;
                ArgInfo _inArgInfo;
-               InternalDictionary _properties;
-\r
-               object []  _outArgs;\r
 
+               object []  _outArgs;
                IMethodCallMessage _callMsg;
-
                LogicalCallContext _callContext;
+               Identity _targetIdentity;
+
+               protected IDictionary ExternalProperties;
+               protected IDictionary InternalProperties;
 
                public MethodResponse (Header[] headers, IMethodCallMessage mcm)
                {
+                       if (mcm != null)
+                       {
+                               _methodName = mcm.MethodName;
+                               _uri = mcm.Uri;
+                               _typeName = mcm.TypeName;
+                               _methodBase = mcm.MethodBase;
+                               _methodSignature = (Type[]) mcm.MethodSignature;
+                       }
+
+                       if (headers != null)
+                       {
+                               foreach (Header header in headers)
+                                       InitMethodProperty (header.Name, header.Value);
+                       }
                }
 
                internal MethodResponse (Exception e, IMethodCallMessage msg) {
@@ -81,8 +96,27 @@ namespace System.Runtime.Remoting.Messaging {
                                CADMessageBase.UnmarshalProperties (Properties, retmsg.PropertiesCount, args);
                }
 
-               protected IDictionary ExternalProperties;
-               protected IDictionary InternalProperties;
+               internal MethodResponse (SerializationInfo info, StreamingContext context) 
+               {
+                       foreach (SerializationEntry entry in info)
+                               InitMethodProperty (entry.Name, entry.Value);
+               }
+
+               internal void InitMethodProperty (string key, object value) 
+               {
+                       switch (key) 
+                       {
+                               case "__TypeName": _typeName = (string) value; break;
+                               case "__MethodName": _methodName = (string) value; break;
+                               case "__MethodSignature": _methodSignature = (Type[]) value; break;
+                               case "__Uri": _uri = (string) value; break;
+                               case "__Return": _returnValue = value; break;
+                               case "__OutArgs": _outArgs = (object[]) value; break;
+                               case "__fault": _exception = (Exception) value; break;
+                               case "__CallContext": _callContext = (LogicalCallContext) value; break;
+                               default: Properties [key] = value; break;
+                       }
+               }
 
                public int ArgCount {
                        get { 
@@ -166,11 +200,10 @@ namespace System.Runtime.Remoting.Messaging {
 
                public virtual IDictionary Properties {
                        get { 
-                               if (null == _properties) {
-                                       _properties = new InternalDictionary (this);
-
-                                       ExternalProperties = _properties;
-                                       InternalProperties = _properties.GetInternalProperties();
+                               if (null == ExternalProperties) {
+                                       MethodReturnDictionary properties = new MethodReturnDictionary (this);
+                                       ExternalProperties = properties;
+                                       InternalProperties = properties.GetInternalProperties();
                                }
                                
                                return ExternalProperties;
@@ -218,10 +251,26 @@ namespace System.Runtime.Remoting.Messaging {
                        throw new NotSupportedException ();
                }
 
-               [MonoTODO]
                public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
                {
-                       throw new NotImplementedException ();
+                       if (_exception == null)
+                       {
+                               info.AddValue ("__TypeName", _typeName);
+                               info.AddValue ("__MethodName", _methodName);
+                               info.AddValue ("__MethodSignature", _methodSignature);
+                               info.AddValue ("__Uri", _uri);
+                               info.AddValue ("__Return", _returnValue);
+                               info.AddValue ("__OutArgs", _outArgs);
+                       }
+                       else
+                               info.AddValue ("__fault", _exception);
+
+                       info.AddValue ("__CallContext", _callContext);
+
+                       if (InternalProperties != null) {
+                               foreach (DictionaryEntry entry in InternalProperties)
+                                       info.AddValue ((string) entry.Key, entry.Value);
+                       }
                } 
 
                public object GetOutArg (int argNum)
@@ -253,14 +302,11 @@ namespace System.Runtime.Remoting.Messaging {
                {
                        throw new NotImplementedException ();
                } 
-\r
-               class InternalDictionary : MethodReturnDictionary {\r
-                       public InternalDictionary(MethodResponse message) : base (message) { }\r
 
-                       protected override void SetMethodProperty (string key, object value) {
-                               if (key == "__Uri") ((MethodResponse) _message).Uri = (string)value;
-                               else base.SetMethodProperty (key, value);
-                       }
+               Identity IInternalMessage.TargetIdentity
+               {
+                       get { return _targetIdentity; }
+                       set { _targetIdentity = value; }
                }
        }
 }
index 1f677e168a12b49ad5a9c06b1083acd3019d4238..270fbbf0a510a71e87f17666fd1ad4ea5d11d2fb 100644 (file)
@@ -16,7 +16,7 @@ using System.Runtime.CompilerServices;
 namespace System.Runtime.Remoting.Messaging {
        
        [Serializable]
-       public class MonoMethodMessage : IMethodCallMessage, IMethodReturnMessage {
+       public class MonoMethodMessage : IMethodCallMessage, IMethodReturnMessage, IInternalMessage {
 
                MonoMethod method;
 
@@ -34,10 +34,13 @@ namespace System.Runtime.Remoting.Messaging {
 
                string uri;
 
-               InternalDictionary properties;
+               MethodCallDictionary properties;
 
                Type[] methodSignature;
 
+               Identity identity;
+
+
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                internal extern void InitMessage (MonoMethod method, object [] out_args);
 
@@ -64,7 +67,7 @@ namespace System.Runtime.Remoting.Messaging {
                
                public IDictionary Properties {
                        get {
-                               if (properties == null) properties = new InternalDictionary (this);
+                               if (properties == null) properties = new MethodCallDictionary (this);
                                return properties;
                        }
                }
@@ -287,19 +290,10 @@ namespace System.Runtime.Remoting.Messaging {
                        return null;
                }
 
-               [Serializable]
-               class InternalDictionary : MethodCallDictionary\r
-               {\r
-                       public InternalDictionary(MonoMethodMessage message) : base (message) \r
-                       { \r
-                       }\r
-
-                       protected override void SetMethodProperty (string key, object value)
-                       {
-                               if (key == "__Uri") ((MonoMethodMessage)_message).Uri = (string)value;
-                               else base.SetMethodProperty (key, value);
-                       }
+               Identity IInternalMessage.TargetIdentity
+               {
+                       get { return identity; }
+                       set { identity = value; }
                }
-
        }
 }
index bd202c0ac32749dafe100d928d518a78c39a5361..78621c3cd6cfa4b1135ec13066d17b40fca18599 100644 (file)
@@ -14,7 +14,7 @@ using System.Reflection;
 namespace System.Runtime.Remoting.Messaging {
 
        [Serializable]
-       public class ReturnMessage : IMethodReturnMessage, IMethodMessage \r
+       public class ReturnMessage : IMethodReturnMessage, IMethodMessage, IInternalMessage \r
        {
                object[] _outArgs;
                LogicalCallContext _callCtx;
@@ -25,7 +25,8 @@ namespace System.Runtime.Remoting.Messaging {
                string _methodName;
                object _methodSignature;
                string _typeName;
-               InternalDictionary _properties;
+               MethodReturnDictionary _properties;
+               Identity _targetIdentity;
 
                public ReturnMessage (object returnValue, object [] outArgs,
                               int outArgCount, LogicalCallContext callCtx,
@@ -97,7 +98,7 @@ namespace System.Runtime.Remoting.Messaging {
 
                public virtual IDictionary Properties {
                        get {
-                               if (_properties == null) _properties = new InternalDictionary (this);
+                               if (_properties == null) _properties = new MethodReturnDictionary (this);
                                return _properties;
                        }
                }
@@ -162,16 +163,10 @@ namespace System.Runtime.Remoting.Messaging {
                        return _methodBase.GetParameters()[arg_num].Name;
                }
 
-
-               class InternalDictionary : MethodReturnDictionary\r
-               {\r
-                       public InternalDictionary(ReturnMessage message) : base (message) { }\r
-
-                       protected override void SetMethodProperty (string key, object value)
-                       {
-                               if (key == "__Uri") ((ReturnMessage)_message).Uri = (string)value;
-                               else base.SetMethodProperty (key, value);
-                       }
-               }\r
+               Identity IInternalMessage.TargetIdentity
+               {
+                       get { return _targetIdentity; }
+                       set { _targetIdentity = value; }
+               }
        }
 }
index 4d5ba867241709c619b051f8bc41e65f63c0ae6f..6fed04b5ecf4e536a7b3c0cb7e43fc3d66001e3a 100644 (file)
@@ -8,6 +8,7 @@
 
 using System;
 using System.Runtime.Remoting;
+using System.Runtime.Remoting.Activation;
 
 namespace System.Runtime.Remoting.Messaging
 {
@@ -18,13 +19,18 @@ namespace System.Runtime.Remoting.Messaging
        {
                public IMessage SyncProcessMessage (IMessage msg)
                {
-                       ServerIdentity identity = RemotingServices.GetMessageTargetIdentity (msg);
-                       return identity.SyncObjectProcessMessage (msg);
+                       if (msg is IConstructionCallMessage)
+                               return ActivationServices.CreateInstanceFromMessage ((IConstructionCallMessage) msg);
+                       else
+                       {
+                               ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
+                               return identity.SyncObjectProcessMessage (msg);
+                       }
                }
 
                public IMessageCtrl AsyncProcessMessage (IMessage msg, IMessageSink replySink)
                {
-                       ServerIdentity identity = RemotingServices.GetMessageTargetIdentity (msg);
+                       ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (msg);
                        return identity.AsyncObjectProcessMessage (msg, replySink);
                }