/// <summary>
        /// Initializes a new instance of the <see cref="ApplicationSessionManager"/> class.
        /// </summary>
        /// <param name="dataBaseConnectivity"><see cref="DataBaseConnectivity" /> to be used for getting the <see cref="SessionFactoryElement" /></param>
        public ApplicationSessionManager(DataBaseConnectivity dataBaseConnectivity)
        {
            try
            {
                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);
            }
            catch (HibernateException hex)
            {
                Logger.Error("Error at ApplicationSessionManager - HibernateException", hex);
                throw;
            }
            catch (Exception ex)
            {
                Logger.Error("Error at ApplicationSessionManager - Exception", ex);
                throw;
            }
        }
 public void Remove(SessionFactoryElement sessionFactory)
 {
     if (BaseIndexOf(sessionFactory) >= 0)
     {
         BaseRemove(sessionFactory.Name);
     }
 }
        /// <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;

            try
            {

                using (SessionFactoryManager sfm = new SessionFactoryManager())
                {
                    sessionFactoryElement = sfm.GetSessionFactoryElementFromName(dataBaseConnectivity);
                }

                Check.Require(sessionFactoryElement != null,
                    "SessionFactoryElement should not be null.");
            }
            catch (Exception ex)
            {
                Logger.Error("Error at GetSessionFactoryElementFromName method", ex);
                throw;
            }

            return sessionFactoryElement;
        }
 public int IndexOf(SessionFactoryElement sessionFactory)
 {
     return BaseIndexOf(sessionFactory);
 }
 public void Add(SessionFactoryElement sessionFactory)
 {
     BaseAdd(sessionFactory);
 }