main
1namespace momoney.database.transactions
2{
3 public interface ISessionProvider
4 {
5 ISession get_the_current_session();
6 }
7
8 public class SessionProvider : ISessionProvider
9 {
10 readonly IContext context;
11 readonly IKey<ISession> session_key;
12
13 public SessionProvider(IContext context, IKey<ISession> session_key)
14 {
15 this.context = context;
16 this.session_key = session_key;
17 }
18
19 public ISession get_the_current_session()
20 {
21 if (!context.contains(session_key)) throw new SessionNotStartedException();
22 return context.value_for(session_key);
23 }
24 }
25}