Ejemplo n.º 1
0
        public static void Configure(Configuration cfg)
        {
            if (configCollection == null)
            {
                configCollection = LoadConfiguration();
            }

            string sessionFactoryName = string.Empty;

            if (cfg.Properties.ContainsKey(NHibernate.Cfg.Environment.SessionFactoryName))
            {
                sessionFactoryName = cfg.Properties[NHibernate.Cfg.Environment.SessionFactoryName];
            }

            INHSConfiguration configuration = configCollection.GetConfiguration(sessionFactoryName);

            if (configuration == null)
            {
                return;
            }

            foreach (KeyValuePair <string, string> pair in configuration.Properties)
            {
                cfg.Properties.Add(pair.Key, pair.Value);
            }
        }
Ejemplo n.º 2
0
        public static void Configure(Configuration cfg)
        {
            if (configCollection == null)
            {
                configCollection = LoadConfiguration();
            }

            string sessionFactoryName = string.Empty;

            if (cfg.Properties.ContainsKey(NHibernate.Cfg.Environment.SessionFactoryName))
            {
                sessionFactoryName = cfg.Properties[NHibernate.Cfg.Environment.SessionFactoryName];
            }

            INHSConfiguration configuration = configCollection.GetConfiguration(sessionFactoryName);

            if (configuration == null)
            {
                return;
            }

            foreach (KeyValuePair<string, string> pair in configuration.Properties)
            {
                cfg.Properties[pair.Key] = pair.Value;
            }
        }
Ejemplo n.º 3
0
        public static void Configure(Configuration nhCfg)
        {
            if (configCollection == null)
                configCollection = LoadConfiguration();

            string sessionFactoryName = string.Empty;

            if (nhCfg.Properties.ContainsKey(NHibernate.Cfg.Environment.SessionFactoryName))
                sessionFactoryName = nhCfg.Properties[NHibernate.Cfg.Environment.SessionFactoryName];

            INHSConfiguration configuration = configCollection.GetConfiguration(sessionFactoryName);

            if (configuration != null)
            {
                foreach (KeyValuePair<string, string> pair in configuration.Properties)
                    nhCfg.Properties.Add(pair.Key, pair.Value);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Return NHibernate.Search Configuration. Loaded using the <c>&lt;nhs-configuration&gt;</c> section
        /// from the application config file, if found, or the file <c>nhsearch.cfg.xml</c> if the
        /// <c>&lt;nhs-configuration&gt;</c> section is not present.
        /// If neither is present, then a blank NHSConfiguration is returned.
        /// </summary>
        public static INHSConfigCollection LoadConfiguration()
        {
            INHSConfigCollection nhshc = ConfigurationManager.GetSection(CfgXmlHelper.CfgSectionName) as INHSConfigCollection;

            if (nhshc != null)
            {
                return(nhshc);
            }

            if (!ConfigFileExists(configFilePath))
            {
                return(new NHSConfigCollection());
            }

            using (XmlTextReader reader = new XmlTextReader(configFilePath))
            {
                return(new NHSConfigCollection(reader));
            }
        }