C# 클래스 Editor.Utils.NHibernateSessionManager

Handles creation and management of sessions and transactions. It is a singleton because building the initial session factory is very expensive. Inspiration for this class came from Chapter 8 of Hibernate in Action by Bauer and King. Although it is a sealed singleton you can use TypeMock (http://www.typemock.com) for more flexible testing.
파일 보기 프로젝트 열기: RIATEAM/MYSTIC

Private Properties

프로퍼티 타입 설명
GetSessionFactoryFor ISessionFactory
GetSessionFrom ISession
IsInWebContext bool
NHibernateSessionManager System

공개 메소드들

메소드 설명
BeginTransactionOn ( string sessionFactoryConfigPath ) : ITransaction
CloseSessionOn ( string sessionFactoryConfigPath ) : void

Flushes anything left in the session and closes the connection.

CommitTransactionOn ( string sessionFactoryConfigPath ) : void
GetSessionFrom ( string sessionFactoryConfigPath ) : ISession
HasOpenTransactionOn ( string sessionFactoryConfigPath ) : bool
RegisterInterceptorOn ( string sessionFactoryConfigPath, IInterceptor interceptor ) : void

Allows you to register an interceptor on a new session. This may not be called if there is already an open session attached to the HttpContext. If you have an interceptor to be used, modify the HttpModule to call this before calling BeginTransaction().

RollbackTransactionOn ( string sessionFactoryConfigPath ) : void

비공개 메소드들

메소드 설명
GetSessionFactoryFor ( string sessionFactoryConfigPath ) : ISessionFactory

This method attempts to find a session factory stored in sessionFactories via its name; if it can't be found it creates a new one and adds it the hashtable.

GetSessionFrom ( string sessionFactoryConfigPath, IInterceptor interceptor ) : ISession

Gets a session with or without an interceptor. This method is not called directly; instead, it gets invoked from other public methods.

IsInWebContext ( ) : bool
NHibernateSessionManager ( ) : System

Private constructor to enforce singleton

메소드 상세

BeginTransactionOn() 공개 메소드

public BeginTransactionOn ( string sessionFactoryConfigPath ) : ITransaction
sessionFactoryConfigPath string
리턴 ITransaction

CloseSessionOn() 공개 메소드

Flushes anything left in the session and closes the connection.
public CloseSessionOn ( string sessionFactoryConfigPath ) : void
sessionFactoryConfigPath string
리턴 void

CommitTransactionOn() 공개 메소드

public CommitTransactionOn ( string sessionFactoryConfigPath ) : void
sessionFactoryConfigPath string
리턴 void

GetSessionFrom() 공개 메소드

public GetSessionFrom ( string sessionFactoryConfigPath ) : ISession
sessionFactoryConfigPath string
리턴 ISession

HasOpenTransactionOn() 공개 메소드

public HasOpenTransactionOn ( string sessionFactoryConfigPath ) : bool
sessionFactoryConfigPath string
리턴 bool

RegisterInterceptorOn() 공개 메소드

Allows you to register an interceptor on a new session. This may not be called if there is already an open session attached to the HttpContext. If you have an interceptor to be used, modify the HttpModule to call this before calling BeginTransaction().
public RegisterInterceptorOn ( string sessionFactoryConfigPath, IInterceptor interceptor ) : void
sessionFactoryConfigPath string
interceptor IInterceptor
리턴 void

RollbackTransactionOn() 공개 메소드

public RollbackTransactionOn ( string sessionFactoryConfigPath ) : void
sessionFactoryConfigPath string
리턴 void