1 namespace Castle
.Services
.Transaction
4 using System
.Threading
;
6 public class TLSActivityManager
: MarshalByRefObject
, IActivityManager
8 private const string Key
= "Castle.Services.Transaction.TLSActivity";
10 private object lockObj
= new object();
11 private static LocalDataStoreSlot dataSlot
;
13 static TLSActivityManager()
15 dataSlot
= Thread
.AllocateNamedDataSlot(Key
);
18 #region MarshalByRefObject
21 ///Obtains a lifetime service object to control the lifetime policy for this instance.
25 ///An object of type <see cref="T:System.Runtime.Remoting.Lifetime.ILease"></see> used to control the lifetime policy for this instance. This is the current lifetime service object for this instance if one exists; otherwise, a new lifetime service object initialized to the value of the <see cref="P:System.Runtime.Remoting.Lifetime.LifetimeServices.LeaseManagerPollTime"></see> property.
28 ///<exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception><filterpriority>2</filterpriority><PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="RemotingConfiguration, Infrastructure" /></PermissionSet>
29 public override object InitializeLifetimeService()
37 /// Gets the current activity.
39 /// <value>The current activity.</value>
40 public Activity CurrentActivity
46 Activity activity
= (Activity
) Thread
.GetData(dataSlot
);
50 activity
= new Activity();
51 Thread
.SetData(dataSlot
, activity
);