From: <pa...@us...> - 2011-03-28 02:39:55
|
Revision: 5558 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5558&view=rev Author: patearl Date: 2011-03-28 02:39:49 +0000 (Mon, 28 Mar 2011) Log Message: ----------- Provide a convenience method for getting dialect-derived properties of configuration. Use derived properties for Linq tests. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2011-03-28 02:32:55 UTC (rev 5557) +++ trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2011-03-28 02:39:49 UTC (rev 5558) @@ -1276,6 +1276,27 @@ set { properties = value; } } + /// <summary> + /// Returns the set of properties computed from the default properties in the dialect combined with the other properties in the configuration. + /// </summary> + /// <returns></returns> + public IDictionary<string, string> GetDerivedProperties() + { + IDictionary<string, string> derivedProperties = new Dictionary<string, string>(); + + if (Properties.ContainsKey(Environment.Dialect)) + { + Dialect.Dialect dialect = Dialect.Dialect.GetDialect(Properties); + foreach (KeyValuePair<string, string> pair in dialect.DefaultProperties) + derivedProperties[pair.Key] = pair.Value; + } + + foreach (KeyValuePair<string, string> pair in Properties) + derivedProperties[pair.Key] = pair.Value; + + return derivedProperties; + } + /// <summary> /// Set the default assembly to use for the mappings added to the configuration /// afterwards. @@ -1692,7 +1713,7 @@ //protected Settings BuildSettings() private Settings BuildSettings() { - var result = settingsFactory.BuildSettings(properties); + var result = settingsFactory.BuildSettings(GetDerivedProperties()); // NH : Set configuration for IdGenerator SQL logging PersistentIdGeneratorParmsNames.SqlStatementLogger.FormatSql = result.SqlStatementLogger.FormatSql; PersistentIdGeneratorParmsNames.SqlStatementLogger.LogToStdout = result.SqlStatementLogger.LogToStdout; Modified: trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2011-03-28 02:32:55 UTC (rev 5557) +++ trunk/nhibernate/src/NHibernate/Cfg/SettingsFactory.cs 2011-03-28 02:39:49 UTC (rev 5558) @@ -29,28 +29,15 @@ { Settings settings = new Settings(); - Dialect.Dialect dialect; try { - dialect = Dialect.Dialect.GetDialect(properties); - Dictionary<string, string> temp = new Dictionary<string, string>(); - - foreach (KeyValuePair<string, string> de in dialect.DefaultProperties) - { - temp[de.Key] = de.Value; - } - foreach (KeyValuePair<string, string> de in properties) - { - temp[de.Key] = de.Value; - } - properties = temp; + settings.Dialect = Dialect.Dialect.GetDialect(properties); } catch (HibernateException he) { log.Warn("No dialect set - using GenericDialect: " + he.Message); - dialect = new GenericDialect(); + settings.Dialect = new GenericDialect(); } - settings.Dialect = dialect; settings.LinqToHqlGeneratorsRegistry = LinqToHqlGeneratorsRegistryFactory.CreateGeneratorsRegistry(properties); Modified: trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs 2011-03-28 02:32:55 UTC (rev 5557) +++ trunk/nhibernate/src/NHibernate.Test/Linq/LinqReadonlyTestsContext.cs 2011-03-28 02:39:49 UTC (rev 5558) @@ -70,7 +70,7 @@ { var file = new FileInfo(scripFileName); string script = file.OpenText().ReadToEnd().Replace("GO", ""); - var connectionProvider = ConnectionProviderFactory.NewConnectionProvider(configuration.Properties); + var connectionProvider = ConnectionProviderFactory.NewConnectionProvider(configuration.GetDerivedProperties()); using (var conn = connectionProvider.GetConnection()) { if (conn.State == ConnectionState.Closed) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |