public NHibernateSessionFactoryBuilder UseConfigurationCache(
     [NotNull] INHibernateConfigurationCache configurationCache)
 {
     _configurationCache = configurationCache ??
                           throw new ArgumentNullException(nameof(configurationCache), "Please provide configuration cache instance.");
     return(this);
 }
        public static Configuration AddConfiguration(
            string factoryKey,
            string[] mappingAssemblies,
            AutoPersistenceModel autoPersistenceModel,
            string cfgFile,
            IDictionary <string, string> cfgProperties,
            string validatorCfgFile,
            IPersistenceConfigurer persistenceConfigurer)
        {
            Configuration config;
            INHibernateConfigurationCache configCache = NHibernateSession.ConfigurationCache;

            if (configCache != null)
            {
                config = configCache.LoadConfiguration(factoryKey, cfgFile, mappingAssemblies);
                if (config != null)
                {
                    return(AddConfiguration(
                               factoryKey,
                               config.BuildSessionFactory(),
                               config,
                               validatorCfgFile));
                }
            }

            config = AddConfiguration(
                factoryKey,
                mappingAssemblies,
                autoPersistenceModel,
                ConfigureNHibernate(cfgFile, cfgProperties),
                validatorCfgFile,
                persistenceConfigurer);

            if (configCache != null)
            {
                configCache.SaveConfiguration(factoryKey, config);
            }

            return(config);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="NHibernateSessionFactoryBuilder" /> class.
 /// </summary>
 public NHibernateSessionFactoryBuilder()
 {
     _configurationCache     = NullNHibernateConfigurationCache.Null;
     _mappingAssemblies      = new List <Assembly>(8);
     _additionalDependencies = new List <string>(8);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NHibernateSessionFactoryBuilder"/> class.
 /// </summary>
 public NHibernateSessionFactoryBuilder()
 {
     this.configurationCache = NullNHibernateConfigurationCache.Null;
     this.mappingAssemblies  = new List <string>();
 }