1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Services
.Transaction
18 using System
.Runtime
.Remoting
.Messaging
;
20 public class CallContextActivityManager
: MarshalByRefObject
, IActivityManager
22 private const string Key
= "Castle.Services.Transaction.Activity";
24 private object lockObj
= new object();
27 /// Initializes a new instance of the <see cref="CallContextActivityManager"/> class.
29 public CallContextActivityManager()
31 CallContext
.SetData(Key
, null);
34 #region MarshalByRefObject
37 ///Obtains a lifetime service object to control the lifetime policy for this instance.
41 ///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.
44 ///<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>
45 public override object InitializeLifetimeService()
53 /// Gets the current activity.
55 /// <value>The current activity.</value>
56 public Activity CurrentActivity
62 Activity activity
= (Activity
) CallContext
.GetData(Key
);
66 activity
= new Activity();
67 CallContext
.SetData(Key
, activity
);