/// <summary> /// Initializes a new instance of the <see cref="UnitOfWorkImpl"/> class. /// </summary> /// <param name="dataBaseConnectivity"><see cref="DataBaseConnectivity" /> to be used for getting the <see cref="SessionFactoryElement" /></param> public UnitOfWorkImpl(DataBaseConnectivity dataBaseConnectivity) { Check.Require(!string.IsNullOrEmpty(dataBaseConnectivity.ToString()), "DataBaseConnectivity should not be null nor empty"); this.sessionFactoryElement = this.GetSessionFactoryElementFromName(dataBaseConnectivity); Check.Require(!string.IsNullOrEmpty(this.sessionFactoryElement.Name) && !string.IsNullOrEmpty(this.sessionFactoryElement.FactoryConfigPath), "SessionFactoryElement's Name and FactoryConfigPath should not be null nor empty"); this.Session = NHibernateSessionManager.Instance.GetSessionFrom(this.sessionFactoryElement.FactoryConfigPath); NHibernateSessionManager.Instance.BeginTransactionOn(this.sessionFactoryElement.FactoryConfigPath); }
/// <summary> /// Removes the specified session factory. /// </summary> /// <param name="sessionFactory">The session factory.</param> public void Remove(SessionFactoryElement sessionFactory) { if (BaseIndexOf(sessionFactory) >= 0) { BaseRemove(sessionFactory.Name); } }
/// <summary> /// Indexes the of. /// </summary> /// <param name="sessionFactory">The session factory.</param> /// <returns></returns> public int IndexOf(SessionFactoryElement sessionFactory) { return BaseIndexOf(sessionFactory); }
/// <summary> /// Adds the specified session factory. /// </summary> /// <param name="sessionFactory">The session factory.</param> public void Add(SessionFactoryElement sessionFactory) { BaseAdd(sessionFactory); }
/// <summary> /// Method to get the <see cref="SessionFactoryElement" /> object based on the <see cref="DataBaseConnectivity" />. /// </summary> /// <param name="dataBaseConnectivity"><see cref="DataBaseConnectivity" /> to be used for getting the <see cref="SessionFactoryElement" /></param> /// <returns>Returns <see cref="SessionFactoryElement" /></returns> private SessionFactoryElement GetSessionFactoryElementFromName(DataBaseConnectivity dataBaseConnectivity) { Check.Require(!string.IsNullOrEmpty(dataBaseConnectivity.ToString()), "DataBaseConnectivity should not be null nor empty"); SessionFactoryElement sessionFactoryElement = null; using (SessionFactoryManager sfm = new SessionFactoryManager()) { sessionFactoryElement = sfm.GetSessionFactoryElementFromName(dataBaseConnectivity); } Check.Require(sessionFactoryElement != null, "SessionFactoryElement should not be null."); return sessionFactoryElement; }