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