Exemple #1
0
        /// <summary>
        /// Configures NHibernate Timeout Persister.
        /// </summary>
        /// <remarks>
        /// Reads configuration settings from <a href="http://msdn.microsoft.com/en-us/library/ms228154.aspx">&lt;appSettings&gt; config section</a> and <a href="http://msdn.microsoft.com/en-us/library/bf7sd233">&lt;connectionStrings&gt; config section</a>.
        /// </remarks>
        /// <example>
        /// An example that shows the minimum configuration:
        /// <code lang="XML" escaped="true">
        ///  <appSettings>
        ///    <!-- other optional settings examples -->
        ///    <add key="NServiceBus/Persistence/NHibernate/connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        ///    <add key="NServiceBus/Persistence/NHibernate/connection.driver_class" value="NHibernate.Driver.Sql2008ClientDriver"/>
        ///    <!-- For more setting see http://www.nhforge.org/doc/nh/en/#configuration-hibernatejdbc and http://www.nhforge.org/doc/nh/en/#configuration-optional -->
        ///  </appSettings>
        ///
        ///  <connectionStrings>
        ///    <!-- Default connection string for all persisters -->
        ///    <add name="NServiceBus/Persistence/NHibernate" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True" />
        ///
        ///    <!-- Optional overrides per persister -->
        ///    <add name="NServiceBus/Persistence/NHibernate/Timeout" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=timeout;Integrated Security=True" />
        ///  </connectionStrings>
        /// </code>
        /// </example>
        /// <param name="config">The configuration object.</param>
        /// <returns>The configuration object.</returns>
        public static Configure UseNHibernateTimeoutPersister(this Configure config)
        {
            var configSection = Configure.GetConfigSection <TimeoutPersisterConfig>();

            if (configSection != null)
            {
                if (configSection.NHibernateProperties.Count == 0)
                {
                    throw new InvalidOperationException(
                              "No NHibernate properties found. Please specify NHibernateProperties in your TimeoutPersisterConfig section");
                }

                foreach (var property in configSection.NHibernateProperties.ToProperties())
                {
                    ConfigureNHibernate.TimeoutPersisterProperties[property.Key] = property.Value;
                }
            }

            ConfigureNHibernate.ConfigureSqlLiteIfRunningInDebugModeAndNoConfigPropertiesSet(ConfigureNHibernate.TimeoutPersisterProperties);

            var properties = ConfigureNHibernate.TimeoutPersisterProperties;

            return(config.UseNHibernateTimeoutPersisterInternal(ConfigureNHibernate.CreateConfigurationWith(properties),
                                                                configSection == null || configSection.UpdateSchema));
        }
        /// <summary>
        /// Configures NHibernate Gateway Persister.
        /// </summary>
        /// <remarks>
        /// Reads configuration settings from <a href="http://msdn.microsoft.com/en-us/library/ms228154.aspx">&lt;appSettings&gt; config section</a> and <a href="http://msdn.microsoft.com/en-us/library/bf7sd233">&lt;connectionStrings&gt; config section</a>.
        /// </remarks>
        /// <example>
        /// An example that shows the minimum configuration:
        /// <code lang="XML" escaped="true">
        ///  <appSettings>
        ///    <!-- optional settings examples -->
        ///    <add key="NServiceBus/Persistence/NHibernate/connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/>
        ///    <add key="NServiceBus/Persistence/NHibernate/connection.driver_class" value="NHibernate.Driver.Sql2008ClientDriver"/>
        ///    <!-- For more setting see http://www.nhforge.org/doc/nh/en/#configuration-hibernatejdbc and http://www.nhforge.org/doc/nh/en/#configuration-optional -->
        ///  </appSettings>
        ///
        ///  <connectionStrings>
        ///    <!-- Default connection string for all persisters -->
        ///    <add name="NServiceBus/Persistence/NHibernate" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True" />
        ///
        ///    <!-- Optional overrides per persister -->
        ///    <add name="NServiceBus/Persistence/NHibernate/Gateway" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=gateway;Integrated Security=True" />
        ///  </connectionStrings>
        /// </code>
        /// </example>
        /// <param name="config">The configuration object.</param>
        /// <returns>The configuration object.</returns>
        public static Configure UseNHibernateGatewayPersister(this Configure config)
        {
            ConfigureNHibernate.ConfigureSqlLiteIfRunningInDebugModeAndNoConfigPropertiesSet(ConfigureNHibernate.GatewayPersisterProperties);

            var properties    = ConfigureNHibernate.GatewayPersisterProperties;
            var configuration = ConfigureNHibernate.CreateConfigurationWith(properties);

            return(config.UseNHibernateGatewayPersisterInternal(configuration));
        }
Exemple #3
0
        public void Should_display_no_warning_and_not_configure_properties_if_debugger_is_not_attached_and_properties_not_set()
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                Assert.Ignore("Can't run this unit test with debugger attached.");
                return;
            }

            var properties = new Dictionary <string, string>();

            ConfigureNHibernate.ConfigureSqlLiteIfRunningInDebugModeAndNoConfigPropertiesSet(properties);

            Assert.AreEqual(0, properties.Count);
        }
Exemple #4
0
        public void Should_display_warning_and_configure_properties_if_debugger_is_attached_and_properties_not_set()
        {
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                Assert.Ignore("Debugger needs to be attached to run this unit test.");
                return;
            }

            var properties = new Dictionary <string, string>();

            ConfigureNHibernate.ConfigureSqlLiteIfRunningInDebugModeAndNoConfigPropertiesSet(properties);

            Assert.IsTrue(properties.ContainsKey("dialect"));
            Assert.AreEqual("NHibernate.Dialect.SQLiteDialect", properties["dialect"]);
        }