2 // System.Runtime.Remoting.Messaging.LogicalCallContext.cs
5 // Dan Lewis (dihlewis@yahoo.co.uk)
6 // Lluis Sanchez Gual (lluis@ximian.com)
8 // 2002 (C) Copyright. Ximian, Inc.
12 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
14 // Permission is hereby granted, free of charge, to any person obtaining
15 // a copy of this software and associated documentation files (the
16 // "Software"), to deal in the Software without restriction, including
17 // without limitation the rights to use, copy, modify, merge, publish,
18 // distribute, sublicense, and/or sell copies of the Software, and to
19 // permit persons to whom the Software is furnished to do so, subject to
20 // the following conditions:
22 // The above copyright notice and this permission notice shall be
23 // included in all copies or substantial portions of the Software.
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System
.Collections
;
35 using System
.Runtime
.Serialization
;
37 namespace System
.Runtime
.Remoting
.Messaging
40 [System
.Runtime
.InteropServices
.ComVisible (true)]
41 public sealed class LogicalCallContext
: ISerializable
, ICloneable
44 CallContextRemotingData _remotingData
= new CallContextRemotingData();
46 internal LogicalCallContext ()
50 internal LogicalCallContext (SerializationInfo info
, StreamingContext context
)
52 foreach (SerializationEntry entry
in info
)
54 if (entry
.Name
== "__RemotingData")
55 _remotingData
= (CallContextRemotingData
) entry
.Value
;
57 SetData (entry
.Name
, entry
.Value
);
65 return (_data
!= null && _data
.Count
> 0);
69 public void FreeNamedDataSlot (string name
)
75 public object GetData (string name
)
77 if (_data
!= null) return _data
[name
];
81 public void GetObjectData (SerializationInfo info
, StreamingContext context
)
83 info
.AddValue ("__RemotingData", _remotingData
);
86 foreach (DictionaryEntry de
in _data
)
87 info
.AddValue ((string)de
.Key
, de
.Value
);
91 public void SetData (string name
, object data
)
93 if (_data
== null) _data
= new Hashtable ();
97 public object Clone ()
99 LogicalCallContext nc
= new LogicalCallContext ();
100 nc
._remotingData
= (CallContextRemotingData
) _remotingData
.Clone ();
103 nc
._data
= new Hashtable ();
104 foreach (DictionaryEntry de
in _data
)
105 nc
._data
[de
.Key
] = de
.Value
;
110 internal Hashtable Datastore
112 get { return _data; }
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
;