@@ -209,27 +209,19 @@ static Environment()
209
209
}
210
210
211
211
GlobalProperties = new Dictionary < string , string > ( ) ;
212
- GlobalProperties [ PropertyUseReflectionOptimizer ] = bool . TrueString ;
213
- LoadGlobalPropertiesFromAppConfig ( ) ;
214
- VerifyProperties ( GlobalProperties ) ;
215
-
216
- BytecodeProviderInstance = BuildBytecodeProvider ( GlobalProperties ) ;
217
- EnableReflectionOptimizer = PropertiesHelper . GetBoolean ( PropertyUseReflectionOptimizer , GlobalProperties ) ;
218
-
219
- if ( EnableReflectionOptimizer )
220
- {
221
- log . Info ( "Using reflection optimizer" ) ;
222
- }
212
+ InitializeGlobalProperties ( LoadGlobalPropertiesFromAppConfig ( ) ) ;
223
213
}
224
214
225
- private static void LoadGlobalPropertiesFromAppConfig ( )
215
+ private static IHibernateConfiguration LoadGlobalPropertiesFromAppConfig ( )
226
216
{
227
- object config = ConfigurationManager . GetSection ( CfgXmlHelper . CfgSectionName ) ;
217
+ var configuration = ConfigurationManager . OpenExeConfiguration ( @"C:\dev\OSS\nhibernate-core\src\NHibernate.Test\bin\Debug\netcoreapp2.0\NHibernate.Test.dll" ) ;
218
+ object config = configuration . GetSection ( CfgXmlHelper . CfgSectionName ) ;
219
+ //object config = ConfigurationManager.GetSection(CfgXmlHelper.CfgSectionName);
228
220
229
221
if ( config == null )
230
222
{
231
223
log . Info ( string . Format ( "{0} section not found in application configuration file" , CfgXmlHelper . CfgSectionName ) ) ;
232
- return ;
224
+ return null ;
233
225
}
234
226
235
227
var nhConfig = config as IHibernateConfiguration ;
@@ -239,18 +231,39 @@ private static void LoadGlobalPropertiesFromAppConfig()
239
231
string . Format (
240
232
"{0} section handler, in application configuration file, is not IHibernateConfiguration, section ignored" ,
241
233
CfgXmlHelper . CfgSectionName ) ) ;
242
- return ;
234
+ return null ;
243
235
}
244
236
245
- GlobalProperties [ PropertyBytecodeProvider ] = nhConfig . ByteCodeProviderType ;
246
- GlobalProperties [ PropertyUseReflectionOptimizer ] = nhConfig . UseReflectionOptimizer . ToString ( ) ;
247
- if ( nhConfig . SessionFactory != null )
237
+ return nhConfig ;
238
+ }
239
+
240
+ public static void InitializeGlobalProperties ( IHibernateConfiguration nhConfig )
241
+ {
242
+ GlobalProperties . Clear ( ) ;
243
+ GlobalProperties [ PropertyUseReflectionOptimizer ] = bool . TrueString ;
244
+
245
+ if ( nhConfig != null )
248
246
{
249
- foreach ( var kvp in nhConfig . SessionFactory . Properties )
247
+ GlobalProperties [ PropertyBytecodeProvider ] = nhConfig . ByteCodeProviderType ;
248
+ GlobalProperties [ PropertyUseReflectionOptimizer ] = nhConfig . UseReflectionOptimizer . ToString ( ) ;
249
+ if ( nhConfig . SessionFactory != null )
250
250
{
251
- GlobalProperties [ kvp . Key ] = kvp . Value ;
251
+ foreach ( var kvp in nhConfig . SessionFactory . Properties )
252
+ {
253
+ GlobalProperties [ kvp . Key ] = kvp . Value ;
254
+ }
252
255
}
253
256
}
257
+
258
+ VerifyProperties ( GlobalProperties ) ;
259
+
260
+ BytecodeProviderInstance = BuildBytecodeProvider ( GlobalProperties ) ;
261
+ EnableReflectionOptimizer = PropertiesHelper . GetBoolean ( PropertyUseReflectionOptimizer , GlobalProperties ) ;
262
+
263
+ if ( EnableReflectionOptimizer )
264
+ {
265
+ log . Info ( "Using reflection optimizer" ) ;
266
+ }
254
267
}
255
268
256
269
internal static void ResetSessionFactoryProperties ( )
0 commit comments