-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathCallSessionContext.cs
39 lines (34 loc) · 1.08 KB
/
CallSessionContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections;
using System.Runtime.Remoting.Messaging;
using NHibernate.Engine;
namespace NHibernate.Context
{
/// <summary>
/// Provides a <see cref="ISessionFactory.GetCurrentSession()">current session</see>
/// for each <see cref="System.Runtime.Remoting.Messaging.CallContext"/>.
/// Not recommended for .NET 2.0 web applications.
/// </summary>
[Serializable]
public class CallSessionContext : MapBasedSessionContext
{
private const string SessionFactoryMapKey = "NHibernate.Context.CallSessionContext.SessionFactoryMapKey";
public CallSessionContext(ISessionFactoryImplementor factory) : base(factory)
{
}
/// <summary>
/// The key is the session factory and the value is the bound session.
/// </summary>
protected override void SetMap(IDictionary value)
{
CallContext.SetData(SessionFactoryMapKey, value);
}
/// <summary>
/// The key is the session factory and the value is the bound session.
/// </summary>
protected override IDictionary GetMap()
{
return CallContext.GetData(SessionFactoryMapKey) as IDictionary;
}
}
}