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 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
);
64 return (_data
!= null && _data
.Count
> 0);
68 public void FreeNamedDataSlot (string name
)
74 public object GetData (string name
)
76 if (_data
!= null) return _data
[name
];
80 public void GetObjectData (SerializationInfo info
, StreamingContext context
)
82 info
.AddValue ("__RemotingData", _remotingData
);
85 foreach (DictionaryEntry de
in _data
)
86 info
.AddValue ((string)de
.Key
, de
.Value
);
90 public void SetData (string name
, object data
)
92 if (_data
== null) _data
= new Hashtable ();
96 public object Clone ()
98 LogicalCallContext nc
= new LogicalCallContext ();
99 nc
._remotingData
= (CallContextRemotingData
) _remotingData
.Clone ();
102 nc
._data
= new Hashtable ();
103 foreach (DictionaryEntry de
in _data
)
104 nc
._data
[de
.Key
] = de
.Value
;
109 internal Hashtable Datastore
111 get { return _data; }
116 internal class CallContextRemotingData
: ICloneable
118 string _logicalCallID
;
120 public string LogicalCallID
122 get { return _logicalCallID; }
123 set { _logicalCallID = value; }
126 public object Clone ()
128 CallContextRemotingData data
= new CallContextRemotingData ();
129 data
._logicalCallID
= _logicalCallID
;