/// <summary> /// Instantiate an SessionHelper using an INHibernateMapper implementation. /// The INHibernateMapper provides basic database information. /// </summary> /// <param name="mapper">INHibernateMapper implementation.</param> /// <exception cref="ArgumentNullException">Exception thrown in the the /// parameter mapper is null.</exception> public SessionHelper(INHibernateMapper mapper) { if (mapper == null) { throw new ArgumentNullException("The INHibernateMapper argument cannot be null"); } _nHibernateHelper = new NHibernateHelper(mapper); }
/// <summary> /// Create an instance of this helper based on a implementation of /// the INHibernateMapper interface. This interface provides info regarding /// a certain database. /// </summary> /// <param name="mapper">INHibernateMapper interface implementation.</param> /// <exception cref="ArgumentNullException">Exception thrown in the the /// parameter mapper is null.</exception> public NHibernateHelper(INHibernateMapper mapper) { if (mapper == null) { throw new ArgumentNullException("The INHibernateMapper argument cannot be null"); } _mapper = mapper; }
/// <summary> /// Based on the INHibernateMapper implementation identifier (given by the method /// INHibernateMapper.GetUniqueIdentifier()), a stored instance of /// the SessionHelper is retrieved. In case this instance /// is not yet stored, a new SessionHelper is created based on the data provided /// by the INHibernateMapper implementation, and this newly-created-SessionHelper /// is then stored in this factory. /// </summary> /// <param name="mapper">INHibernateMapper implementation.</param> /// <returns>An instance of the SessionHelper, based on a INHibernateMapper implementation.</returns> public static SessionHelper GetSessionHelper(INHibernateMapper mapper) { SessionHelper sessionHelper = null; // in case the SessionHelper is already stored, retrieve it. if (_sessionMap.ContainsKey(mapper.GetUniqueIdentifier())) { sessionHelper = _sessionMap[mapper.GetUniqueIdentifier()]; } // the session helper is not stored else { // create a new SessionHelper and store it sessionHelper = new SessionHelper(mapper); _sessionMap.Add(mapper.GetUniqueIdentifier(), sessionHelper); } return sessionHelper; }