by Patrik).
* CallContext.cs: Impplemented.
* LogicalCallContext.cs: Implemented.
* MonoMethodMessage.cs: Added setter for LogicalCallContext property.
svn path=/trunk/mcs/; revision=17338
// 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
// 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
{
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
+ {
}
}
+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
-//\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;
+ }
+}
+}
+
get {
if (null == args)
return 0;
+// Lluis Sanchez Gual (lluis@ximian.com)
return args.Length;
}
get {
return ctx;
}
+
+ set {
+ ctx = value;
+ }
}
public MethodBase MethodBase {