From e6a1fb8327042dc3069adb7143f599c69c999401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?= <12201973+fredericdelaporte@users.noreply.github.com> Date: Wed, 15 Jul 2020 13:12:06 +0200 Subject: [PATCH 1/2] Document the configuration provider --- doc/reference/modules/configuration.xml | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/reference/modules/configuration.xml b/doc/reference/modules/configuration.xml index bef10305634..b86b48a1f37 100644 --- a/doc/reference/modules/configuration.xml +++ b/doc/reference/modules/configuration.xml @@ -433,6 +433,39 @@ var session = sessions.OpenSession(conn); + + Using a custom configuration provider + + + By default, NHibernate attempts to read the hibernate-configuration section + through the .Net ConfigurationManager. Some environments do not support it, so + NHibernate provide a way to set a custom configuration provider, through the + NHibernate.Cfg.ConfigurationProvider.Current property. + + + + To disable the configuration provider, in case you configure NHibernate entirely programmatically, + set this property to null. + + + + + + To provide directly the System.Configuration.Configuration instance to use, assign + the Current property with an instance of + NHibernate.Cfg.SystemConfigurationProvider built with your + Configuration instance. + + + + + + You may also derive a custom provider from NHibernate.Cfg.ConfigurationProvider, + implements its abstract methods, and assign an instance of your custom provider to the + NHibernate.Cfg.ConfigurationProvider.Current property. + + + Optional configuration properties From eba011896b126603acbebfc273ddc28d75f46df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Delaporte?= <12201973+fredericdelaporte@users.noreply.github.com> Date: Thu, 16 Jul 2020 12:40:23 +0200 Subject: [PATCH 2/2] Fix a typo and add some more information --- doc/reference/modules/configuration.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/reference/modules/configuration.xml b/doc/reference/modules/configuration.xml index b86b48a1f37..8540764df70 100644 --- a/doc/reference/modules/configuration.xml +++ b/doc/reference/modules/configuration.xml @@ -439,7 +439,7 @@ var session = sessions.OpenSession(conn); By default, NHibernate attempts to read the hibernate-configuration section through the .Net ConfigurationManager. Some environments do not support it, so - NHibernate provide a way to set a custom configuration provider, through the + NHibernate provides a way to set a custom configuration provider, through the NHibernate.Cfg.ConfigurationProvider.Current property. @@ -464,6 +464,12 @@ var session = sessions.OpenSession(conn); implements its abstract methods, and assign an instance of your custom provider to the NHibernate.Cfg.ConfigurationProvider.Current property. + + + Changes of the ConfigurationProvider.Current property value are to be done very + early in the application lifecycle, before any other call on a NHibernate API. Otherwise they + may not be taken into account. +