From: Michael D. <mik...@us...> - 2004-07-12 01:28:59
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7723/Cfg Modified Files: Configuration.cs Environment.cs Log Message: Fixed Configuration so it is possible to configure with out settings in the app.config/web.config http://jira.nhibernate.org:8080/browse/NH-67 Index: Configuration.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Configuration.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Configuration.cs 2 Jul 2004 16:58:26 -0000 1.15 --- Configuration.cs 12 Jul 2004 01:28:50 -0000 1.16 *************** *** 645,653 **** string value = node.FirstChild.Value; log.Debug(name + "=" + value); ! properties.Add(name, value); ! if ( !name.StartsWith("hibernate") ) properties.Add("hibernate." + name, value); } } public Configuration Configure() { --- 645,663 ---- string value = node.FirstChild.Value; log.Debug(name + "=" + value); ! properties[name] = value; ! if ( !name.StartsWith("hibernate") ) ! { ! properties["hibernate." + name] = value; ! } } } + /// <summary> + /// Configure NHibernate using the file "hibernate.cfg.xml" + /// </summary> + /// <returns>A Configuration object initialized with the file.</returns> + /// <remarks> + /// Calling Configure() will overwrite the values set in app.config or web.config + /// </remarks> public Configuration Configure() { *************** *** 656,659 **** --- 666,677 ---- } + /// <summary> + /// Configure NHibernate using the file specified. + /// </summary> + /// <param name="resource">The location of the Xml file to use to configure NHibernate.</param> + /// <returns>A Configuration object initialized with the file.</returns> + /// <remarks> + /// Calling Configure(string) will overwrite the values set in app.config or web.config + /// </remarks> public Configuration Configure(string resource) { Index: Environment.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Cfg/Environment.cs,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Environment.cs 11 Jul 2004 21:04:56 -0000 1.13 --- Environment.cs 12 Jul 2004 01:28:50 -0000 1.14 *************** *** 4,11 **** using System.Collections.Specialized; using System.Configuration; - using NHibernate.Util; ! namespace NHibernate.Cfg { /// <summary> /// Provides access to configuration info --- 4,12 ---- using System.Collections.Specialized; using System.Configuration; ! using NHibernate.Util; + namespace NHibernate.Cfg + { /// <summary> /// Provides access to configuration info *************** *** 25,29 **** /// </list> /// </remarks> ! public class Environment { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Environment)); --- 26,31 ---- /// </list> /// </remarks> ! public class Environment ! { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Environment)); *************** *** 31,35 **** private static IDictionary isolationLevels = new Hashtable(); ! private const string Version = "prealpha3"; public const string ConnectionProvider = "hibernate.connection.provider"; --- 33,37 ---- private static IDictionary isolationLevels = new Hashtable(); ! private const string Version = "prealpha"; public const string ConnectionProvider = "hibernate.connection.provider"; *************** *** 57,70 **** public const string UseScrollableResultSet = "hibernate.jdbc.use_scrollable_resultset"; ! static Environment() { log4net.Config.DOMConfigurator.Configure(); - NameValueCollection props = System.Configuration.ConfigurationSettings.GetConfig("nhibernate") as NameValueCollection; - if (props==null) throw new HibernateException("no nhibernate settings available"); - - foreach(string key in props.Keys) { - properties[key] = props[key]; - } - isolationLevels.Add( System.Data.IsolationLevel.Chaos, "NONE" ); isolationLevels.Add( System.Data.IsolationLevel.ReadUncommitted, "READ_UNCOMMITTED" ); --- 59,66 ---- public const string UseScrollableResultSet = "hibernate.jdbc.use_scrollable_resultset"; ! static Environment() ! { log4net.Config.DOMConfigurator.Configure(); isolationLevels.Add( System.Data.IsolationLevel.Chaos, "NONE" ); isolationLevels.Add( System.Data.IsolationLevel.ReadUncommitted, "READ_UNCOMMITTED" ); *************** *** 72,82 **** isolationLevels.Add( System.Data.IsolationLevel.RepeatableRead, "REPEATABLE_READ" ); isolationLevels.Add( System.Data.IsolationLevel.Serializable, "SERIALIZABLE" ); } ! public static IDictionary Properties { get { return properties; } } ! public static bool UseStreamsForBinary { get { return true; } } --- 68,94 ---- isolationLevels.Add( System.Data.IsolationLevel.RepeatableRead, "REPEATABLE_READ" ); isolationLevels.Add( System.Data.IsolationLevel.Serializable, "SERIALIZABLE" ); + + NameValueCollection props = System.Configuration.ConfigurationSettings.GetConfig("nhibernate") as NameValueCollection; + if (props==null) + { + log.Debug("no hibernate settings in app.config/web.config were found"); + return; + } + + foreach(string key in props.Keys) + { + properties[key] = props[key]; + } + + } ! public static IDictionary Properties ! { get { return properties; } } ! public static bool UseStreamsForBinary ! { get { return true; } } |