* CADMessages.cs: Enabled smuggeling of primitive type parameters (as suggested
authorLluis Sanchez <lluis@novell.com>
Thu, 14 Aug 2003 19:35:42 +0000 (19:35 -0000)
committerLluis Sanchez <lluis@novell.com>
Thu, 14 Aug 2003 19:35:42 +0000 (19:35 -0000)
  by Patrik).
* CallContext.cs: Impplemented.
* LogicalCallContext.cs: Implemented.
* MonoMethodMessage.cs: Added setter for LogicalCallContext property.

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

mcs/class/corlib/System.Runtime.Remoting.Messaging/CADMessages.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/CallContext.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/ChangeLog
mcs/class/corlib/System.Runtime.Remoting.Messaging/LogicalCallContext.cs
mcs/class/corlib/System.Runtime.Remoting.Messaging/MonoMethodMessage.cs

index 8373fd26ffda32fe41768fce49d2057aea287bc9..88a2441d13f54828696f7af59fd804ef4da94912 100755 (executable)
@@ -78,18 +78,11 @@ namespace System.Runtime.Remoting.Messaging {
                // We can ignore marshalling for string and primitive types
                private static bool IsPossibleToIgnoreMarshal (object obj) {
 
-                       // until this is more tested, we disable it....
-                       return false;
-
-/*            if (obj is string) 
-                               return true;
-
                        Type objType = obj.GetType();
                        if (objType.IsPrimitive || objType == typeof(void))
                                return true;
                        
                        return false;
-*/
                }
 
                // Checks an argument if it's possible to pass without marshalling and
index b3b1dee70adf34452444fe8d4ad5d1d4fbf34bc4..56c136667a5136ce47d091463d8e6ca0bac33a8d 100644 (file)
@@ -2,16 +2,18 @@
 // System.Runtime.Remoting.Messaging.CallContext.cs
 //
 // Author: Jaime Anguiano Olarra (jaime@gnome.org)
+//         Lluis Sanchez Gual (lluis@ximian.com)
 //
 // (c) 2002, Jaime Anguiano Olarra
 //
-// FIXME: This is just a skeleton for practical purposes.
 ///<summary>
 ///Provides several properties that come with the execution code path.
 ///This class is sealed.
 ///</summary>
 
 using System;
+using System.Threading;
+using System.Collections;
 
 namespace System.Runtime.Remoting.Messaging 
 {
@@ -20,34 +22,76 @@ namespace System.Runtime.Remoting.Messaging
        public sealed class CallContext 
        {
                // public methods
-               [MonoTODO]
                public static void FreeNamedDataSlot (string name) 
                {
-                       throw new NotImplementedException ();
+                       Datastore.Remove (name);
                }
 
-               [MonoTODO]
                public static object GetData (string name) 
                {
-                       throw new NotImplementedException ();
+                       return Datastore [name];
                }
 
-               [MonoTODO]
                public static Header[] GetHeaders () 
                {
-                       throw new NotImplementedException ();
+                       return (Header[]) Datastore ["__Headers"];
                }
 
-               [MonoTODO]
                public static void SetData (string name, object data) 
                {
-                       throw new NotImplementedException ();
+                       Datastore [name] = data;
                }
 
-               [MonoTODO]
                public static void SetHeaders (Header[] headers) 
                {
-                       throw new NotImplementedException ();
+                       Datastore ["__Headers"] = headers;
                }
+
+               internal static LogicalCallContext CreateLogicalCallContext ()
+               {
+                       LocalDataStoreSlot ds = Thread.GetNamedDataSlot ("__CallContext");
+                       Hashtable res = (Hashtable) Thread.GetData (ds);
+
+                       LogicalCallContext ctx = new LogicalCallContext();
+                       if (res == null) return ctx;
+
+                       foreach (DictionaryEntry entry in res)
+                               if (entry.Value is ILogicalThreadAffinative)
+                                       ctx.SetData ((string)entry.Key, entry.Value);
+
+                       return ctx;
+               }
+
+               internal static void SetCurrentCallContext (LogicalCallContext ctx)
+               {
+                       Hashtable data = ctx.Datastore;
+                       if (data == null) return;
+
+                       foreach (DictionaryEntry entry in data)
+                               SetData ((string)entry.Key, entry.Value);
+               }
+
+               internal static void ResetCurrentCallContext ()
+               {
+                       LocalDataStoreSlot ds = Thread.GetNamedDataSlot ("__CallContext");
+                       Thread.SetData (ds, null);
+               }
+
+               private static Hashtable Datastore
+               {
+                       get {
+                               LocalDataStoreSlot ds = Thread.GetNamedDataSlot ("__CallContext");
+                               Hashtable res = (Hashtable) Thread.GetData (ds);
+                               if (res == null) {
+                                       res = new Hashtable ();
+                                       Thread.SetData (ds, res);
+                               }
+                               return res;
+                       }
+               }
+       }
+
+       public interface ILogicalThreadAffinative
+       {
        }
 }
index 633a1d2e1aa27db6a62cdb277744bcaf0a79e3ab..fc77edec471a390837a8a0ec24b8cf0b9163b4c8 100644 (file)
@@ -1,3 +1,11 @@
+2003-08-14  Lluis Sanchez Gual <lluis@ximian.com>
+
+       * CADMessages.cs: Enabled smuggeling of primitive type parameters (as suggested
+         by Patrik).
+       * CallContext.cs: Impplemented.
+       * LogicalCallContext.cs: Implemented.
+       * MonoMethodMessage.cs: Added setter for LogicalCallContext property.
+
 2003-07-25  Lluis Sanchez Gual <lluis@ximian.com>
 
        * ArgInfo.cs: Use Type.IsByRef to check if a parameter is a ref or
index a9e44a0ca4b21a5b5a590d213d84dddbe1fd6b59..556a307980eb8779834e9adddcc045cc4f9c9814 100644 (file)
-//\r
-// System.Runtime.Remoting.Messaging.LogicalCallContext.cs\r
-//\r
-// Author:\r
-//   Dan Lewis (dihlewis@yahoo.co.uk)\r
-//\r
-// (C) 2002\r
-//\r
-// Stubbed.\r
-//\r
-\r
-using System.Runtime.Serialization;\r
-\r
-namespace System.Runtime.Remoting.Messaging {\r
-\r
-       [MonoTODO]\r
+//
+// System.Runtime.Remoting.Messaging.LogicalCallContext.cs
+//
+// Author:
+//   Dan Lewis (dihlewis@yahoo.co.uk)
+//   Lluis Sanchez Gual (lluis@ximian.com)
+//
+// 2002 (C) Copyright. Ximian, Inc.
+//
+
+using System.Collections;
+using System.Runtime.Serialization;
+
+namespace System.Runtime.Remoting.Messaging {
+
+       [MonoTODO]
        [Serializable]
-       public sealed class LogicalCallContext : ISerializable, ICloneable {\r
-
-               internal LogicalCallContext () {}
-
-               public bool HasInfo {\r
-                       get { return false; }\r
-               }\r
-\r
-               public void FreeNamedDataSlot (string name) {\r
-               }\r
-\r
-               public object GetData (string name) {\r
-                       return null;\r
-               }\r
-\r
-               public void GetObjectData (SerializationInfo info, StreamingContext context) {\r
-               }\r
-\r
-               public void SetData (string name, object data) {\r
-               }\r
-\r
-               public object Clone () {\r
-                       return null;\r
-               }\r
-       }\r
-}\r
+       public sealed class LogicalCallContext : ISerializable, ICloneable
+       {
+               Hashtable _data;
+               CallContextRemotingData _remotingData = new CallContextRemotingData();
+
+               internal LogicalCallContext ()
+               {
+               }
+
+               internal LogicalCallContext (SerializationInfo info, StreamingContext context)
+               {
+                       foreach (SerializationEntry entry in info)
+                       {
+                               if (entry.Name == "__RemotingData")
+                                       _remotingData = (CallContextRemotingData) entry.Value;
+                               else
+                                       SetData (entry.Name, entry.Value);
+                       }
+               }
+
+               public bool HasInfo
+               {
+                       get
+                       {
+                               return (_data != null && _data.Count > 0);
+                       }
+               }
+
+               public void FreeNamedDataSlot (string name)
+               {
+                       if (_data != null)
+                               _data.Remove (name);
+               }
+
+               public object GetData (string name)
+               {
+                       if (_data != null) return _data [name];
+                       else return null;
+               }
+
+               public void GetObjectData (SerializationInfo info, StreamingContext context)
+               {
+                       info.AddValue ("__RemotingData", _remotingData);
+                       if (_data != null)
+                       {
+                               foreach (DictionaryEntry de in _data)
+                                       info.AddValue ((string)de.Key, de.Value);
+                       }
+               }
+
+               public void SetData (string name, object data)
+               {
+                       if (_data == null) _data = new Hashtable ();
+                       _data [name] = data;
+               }
+
+               public object Clone ()
+               {
+                       LogicalCallContext nc = new LogicalCallContext ();
+                       nc._remotingData = (CallContextRemotingData) _remotingData.Clone ();
+                       if (_data != null)
+                       {
+                               nc._data = new Hashtable ();
+                               foreach (DictionaryEntry de in _data)
+                                       nc._data [de.Key] = de.Value;
+                       }
+                       return nc;
+               }
+
+               internal Hashtable Datastore
+               {
+                       get { return _data; }
+               }
+       }
+
+
+       internal class CallContextRemotingData : ICloneable
+       {
+               string _logicalCallID;
+
+               public string LogicalCallID
+               {
+                       get { return _logicalCallID; }
+                       set { _logicalCallID = value; }
+               }
+
+               public object Clone ()
+               {
+                       CallContextRemotingData data = new CallContextRemotingData ();
+                       data._logicalCallID = _logicalCallID;
+                       return data;
+               }
+}
+}
+
index 48856e53bd6e6c9959c5546bd6d7ed8d28f32c4f..1e7fa10a216a6a784771f43716ca43c98d1d1227 100644 (file)
@@ -78,6 +78,7 @@ namespace System.Runtime.Remoting.Messaging {
                        get {
                                if (null == args)
                                        return 0;
+//         Lluis Sanchez Gual (lluis@ximian.com)
 
                                return args.Length;
                        }
@@ -99,6 +100,10 @@ namespace System.Runtime.Remoting.Messaging {
                        get {
                                return ctx;
                        }
+
+                       set {
+                               ctx = value;
+                       }
                }
 
                public MethodBase MethodBase {