2 // System.Runtime.Remoting.Messaging.LogicalCallContext.cs
5 // Dan Lewis (dihlewis@yahoo.co.uk)
6 // Lluis Sanchez Gual (lluis@ximian.com)
7 // Marek Safar (marek.safar@gmail.com)
9 // 2002 (C) Copyright. Ximian, Inc.
10 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
11 // Copyright (C) 2014 Xamarin Inc (http://www.xamarin.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.
33 using System.Collections;
34 using System.Runtime.Serialization;
36 namespace System.Runtime.Remoting.Messaging
39 [System.Runtime.InteropServices.ComVisible (true)]
40 public sealed class LogicalCallContext : ISerializable, ICloneable
43 CallContextRemotingData _remotingData = new CallContextRemotingData();
45 internal LogicalCallContext ()
49 internal LogicalCallContext (SerializationInfo info, StreamingContext context)
51 foreach (SerializationEntry entry in info)
53 if (entry.Name == "__RemotingData")
54 _remotingData = (CallContextRemotingData) entry.Value;
56 SetData (entry.Name, entry.Value);
62 return _data != null && _data.Count > 0;
66 public void FreeNamedDataSlot (string name)
72 public object GetData (string name)
74 return _data != null ? _data [name] : null;
77 public void GetObjectData (SerializationInfo info, StreamingContext context)
79 info.AddValue ("__RemotingData", _remotingData);
82 foreach (DictionaryEntry de in _data)
83 info.AddValue ((string)de.Key, de.Value);
87 public void SetData (string name, object data)
90 _data = new Hashtable ();
94 public object Clone ()
96 LogicalCallContext nc = new LogicalCallContext ();
97 nc._remotingData = (CallContextRemotingData) _remotingData.Clone ();
99 nc._data = (Hashtable) _data.Clone ();
104 internal Hashtable Datastore {
105 get { return _data; }
106 set { _data = value; }
109 internal CallContextRemotingData RemotingData {
111 return _remotingData;
117 internal class CallContextRemotingData : ICloneable
119 string _logicalCallID;
121 public string LogicalCallID
123 get { return _logicalCallID; }
124 set { _logicalCallID = value; }
127 public object Clone ()
129 CallContextRemotingData data = new CallContextRemotingData ();
130 data._logicalCallID = _logicalCallID;