blob: 8f5a7abede88bcd5388d4f30b7f1377dd71d271f (
plain)
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
|
namespace Gorilla.Commons.Infrastructure.Transactions
{
public interface ISessionProvider
{
ISession get_the_current_session();
}
public class SessionProvider : ISessionProvider
{
readonly IContext context;
readonly IKey<ISession> session_key;
public SessionProvider(IContext context, IKey<ISession> session_key)
{
this.context = context;
this.session_key = session_key;
}
public ISession get_the_current_session()
{
if (!context.contains(session_key)) throw new SessionNotStartedException();
return context.value_for(session_key);
}
}
}
|