6
6
using NHibernate . Dialect ;
7
7
using NHibernate . Driver ;
8
8
using NHibConfiguration = NHibernate . Cfg . Configuration ;
9
+ using NHibEnvironment = NHibernate . Cfg . Environment ;
9
10
10
11
namespace FluentNHibernate . Cfg . Db
11
12
{
@@ -17,37 +18,31 @@ public abstract class PersistenceConfiguration<TThisConfiguration, TConnectionSt
17
18
where TThisConfiguration : PersistenceConfiguration < TThisConfiguration , TConnectionString >
18
19
where TConnectionString : ConnectionStringBuilder , new ( )
19
20
{
20
- protected const string DialectKey = "dialect" ; // Newer one, but not supported by everything
21
+ protected const string DialectKey = NHibEnvironment . Dialect ; // Newer one, but not supported by everything
21
22
protected const string AltDialectKey = "hibernate.dialect" ; // Some older NHib tools require this
22
23
protected const string DefaultSchemaKey = "default_schema" ;
23
24
protected const string UseOuterJoinKey = "use_outer_join" ;
24
- protected const string MaxFetchDepthKey = "max_fetch_depth" ;
25
- protected const string UseReflectionOptimizerKey = "use_reflection_optimizer" ;
26
- protected const string QuerySubstitutionsKey = "query.substitutions" ;
27
- protected const string ShowSqlKey = "show_sql" ;
28
- protected const string FormatSqlKey = "format_sql" ;
29
-
30
- protected const string CollectionTypeFactoryClassKey = NHibernate . Cfg . Environment . CollectionTypeFactoryClass ;
31
- protected const string ConnectionProviderKey = "connection.provider" ;
25
+ protected const string MaxFetchDepthKey = NHibEnvironment . MaxFetchDepth ;
26
+ protected const string UseReflectionOptimizerKey = NHibEnvironment . PropertyUseReflectionOptimizer ;
27
+ protected const string QuerySubstitutionsKey = NHibEnvironment . QuerySubstitutions ;
28
+ protected const string ShowSqlKey = NHibEnvironment . ShowSql ;
29
+ protected const string FormatSqlKey = NHibEnvironment . FormatSql ;
30
+
31
+ protected const string ConnectionProviderKey = NHibEnvironment . ConnectionProvider ;
32
32
protected const string DefaultConnectionProviderClassName = "NHibernate.Connection.DriverConnectionProvider" ;
33
- protected const string DriverClassKey = "connection.driver_class" ;
34
- protected const string ConnectionStringKey = "connection.connection_string" ;
35
- const string IsolationLevelKey = "connection.isolation" ;
36
- protected const string ProxyFactoryFactoryClassKey = "proxyfactory.factory_class" ;
37
- protected const string DefaultProxyFactoryFactoryClassName = "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" ;
38
- protected const string AdoNetBatchSizeKey = "adonet.batch_size" ;
39
- protected const string CurrentSessionContextClassKey = "current_session_context_class" ;
33
+ protected const string DriverClassKey = NHibEnvironment . ConnectionDriver ;
34
+ protected const string ConnectionStringKey = NHibEnvironment . ConnectionString ;
35
+ protected const string IsolationLevelKey = NHibEnvironment . Isolation ;
36
+ protected const string AdoNetBatchSizeKey = NHibEnvironment . BatchSize ;
40
37
41
38
private readonly Dictionary < string , string > values = new Dictionary < string , string > ( ) ;
42
39
43
40
private bool nextBoolSettingValue = true ;
44
41
private readonly TConnectionString connectionString ;
45
- private readonly CacheSettingsBuilder cache = new CacheSettingsBuilder ( ) ;
46
42
47
43
protected PersistenceConfiguration ( )
48
44
{
49
45
values [ ConnectionProviderKey ] = DefaultConnectionProviderClassName ;
50
- values [ ProxyFactoryFactoryClassKey ] = DefaultProxyFactoryFactoryClassName ;
51
46
connectionString = new TConnectionString ( ) ;
52
47
}
53
48
@@ -56,22 +51,14 @@ protected virtual IDictionary<string, string> CreateProperties()
56
51
if ( connectionString . IsDirty )
57
52
Raw ( ConnectionStringKey , connectionString . Create ( ) ) ;
58
53
59
- if ( cache . IsDirty )
60
- {
61
- foreach ( var pair in cache . Create ( ) )
62
- {
63
- Raw ( pair . Key , pair . Value ) ;
64
- }
65
- }
66
-
67
54
return values ;
68
55
}
69
56
70
57
public NHibConfiguration ConfigureProperties ( NHibConfiguration nhibernateConfig )
71
58
{
72
59
var settings = CreateProperties ( ) ;
73
60
74
- nhibernateConfig . SetProperties ( settings ) ;
61
+ nhibernateConfig . AddProperties ( settings ) ;
75
62
76
63
return nhibernateConfig ;
77
64
}
@@ -276,24 +263,6 @@ public TThisConfiguration ConnectionString(string value)
276
263
return ( TThisConfiguration ) this ;
277
264
}
278
265
279
- /// <summary>
280
- /// Configure caching.
281
- /// </summary>
282
- /// <example>
283
- /// Cache(x =>
284
- /// {
285
- /// x.UseQueryCache();
286
- /// x.UseMinimalPuts();
287
- /// });
288
- /// </example>
289
- /// <param name="cacheExpression">Closure for configuring caching</param>
290
- /// <returns>Configuration builder</returns>
291
- public TThisConfiguration Cache ( Action < CacheSettingsBuilder > cacheExpression )
292
- {
293
- cacheExpression ( cache ) ;
294
- return ( TThisConfiguration ) this ;
295
- }
296
-
297
266
/// <summary>
298
267
/// Sets a raw property on the NHibernate configuration. Use this method
299
268
/// if there isn't a specific option available in the API.
@@ -307,76 +276,6 @@ public TThisConfiguration Raw(string key, string value)
307
276
return ( TThisConfiguration ) this ;
308
277
}
309
278
310
- /// <summary>
311
- /// Sets the collectiontype.factory_class property.
312
- /// NOTE: NHibernate 2.1 only
313
- /// </summary>
314
- /// <param name="collectionTypeFactoryClass">factory class</param>
315
- /// <returns>Configuration</returns>
316
- public TThisConfiguration CollectionTypeFactory ( string collectionTypeFactoryClass )
317
- {
318
- values [ CollectionTypeFactoryClassKey ] = collectionTypeFactoryClass ;
319
- return ( TThisConfiguration ) this ;
320
- }
321
-
322
- /// <summary>
323
- /// Sets the collectiontype.factory_class property.
324
- /// NOTE: NHibernate 2.1 only
325
- /// </summary>
326
- /// <param name="collectionTypeFactoryClass">factory class</param>
327
- /// <returns>Configuration</returns>
328
- public TThisConfiguration CollectionTypeFactory ( Type collectionTypeFactoryClass )
329
- {
330
- values [ CollectionTypeFactoryClassKey ] = collectionTypeFactoryClass . AssemblyQualifiedName ;
331
- return ( TThisConfiguration ) this ;
332
- }
333
-
334
- /// <summary>
335
- /// Sets the collectiontype.factory_class property.
336
- /// NOTE: NHibernate 2.1 only
337
- /// </summary>
338
- /// <typeparam name="TCollectionTypeFactory">factory class</typeparam>
339
- /// <returns>Configuration</returns>
340
- public TThisConfiguration CollectionTypeFactory < TCollectionTypeFactory > ( ) where TCollectionTypeFactory : ICollectionTypeFactory
341
- {
342
- return CollectionTypeFactory ( typeof ( TCollectionTypeFactory ) ) ;
343
- }
344
-
345
- /// <summary>
346
- /// Sets the proxyfactory.factory_class property.
347
- /// NOTE: NHibernate 2.1 only
348
- /// </summary>
349
- /// <param name="proxyFactoryFactoryClass">factory class</param>
350
- /// <returns>Configuration</returns>
351
- public TThisConfiguration ProxyFactoryFactory ( string proxyFactoryFactoryClass )
352
- {
353
- values [ ProxyFactoryFactoryClassKey ] = proxyFactoryFactoryClass ;
354
- return ( TThisConfiguration ) this ;
355
- }
356
-
357
- /// <summary>
358
- /// Sets the proxyfactory.factory_class property.
359
- /// NOTE: NHibernate 2.1 only
360
- /// </summary>
361
- /// <param name="proxyFactoryFactory">factory class</param>
362
- /// <returns>Configuration</returns>
363
- public TThisConfiguration ProxyFactoryFactory ( Type proxyFactoryFactory )
364
- {
365
- values [ ProxyFactoryFactoryClassKey ] = proxyFactoryFactory . AssemblyQualifiedName ;
366
- return ( TThisConfiguration ) this ;
367
- }
368
-
369
- /// <summary>
370
- /// Sets the proxyfactory.factory_class property.
371
- /// NOTE: NHibernate 2.1 only
372
- /// </summary>
373
- /// <typeparam name="TProxyFactoryFactory">factory class</typeparam>
374
- /// <returns>Configuration</returns>
375
- public TThisConfiguration ProxyFactoryFactory < TProxyFactoryFactory > ( ) where TProxyFactoryFactory : IProxyFactoryFactory
376
- {
377
- return ProxyFactoryFactory ( typeof ( TProxyFactoryFactory ) ) ;
378
- }
379
-
380
279
/// <summary>
381
280
/// Sets the adonet.batch_size property.
382
281
/// </summary>
@@ -388,27 +287,6 @@ public TThisConfiguration AdoNetBatchSize(int size)
388
287
return ( TThisConfiguration ) this ;
389
288
}
390
289
391
- /// <summary>
392
- /// Sets the current_session_context_class property.
393
- /// </summary>
394
- /// <param name="currentSessionContextClass">current session context class</param>
395
- /// <returns>Configuration</returns>
396
- public TThisConfiguration CurrentSessionContext ( string currentSessionContextClass )
397
- {
398
- values [ CurrentSessionContextClassKey ] = currentSessionContextClass ;
399
- return ( TThisConfiguration ) this ;
400
- }
401
-
402
- /// <summary>
403
- /// Sets the current_session_context_class property.
404
- /// </summary>
405
- /// <typeparam name="TSessionContext">Implementation of ICurrentSessionContext to use</typeparam>
406
- /// <returns>Configuration</returns>
407
- public TThisConfiguration CurrentSessionContext < TSessionContext > ( ) where TSessionContext : NHibernate . Context . ICurrentSessionContext
408
- {
409
- return CurrentSessionContext ( typeof ( TSessionContext ) . AssemblyQualifiedName ) ;
410
- }
411
-
412
290
/// <summary>
413
291
/// Sets the connection isolation level. NHibernate setting: connection.isolation
414
292
/// </summary>
0 commit comments