IConfigurationFactory¶
IConfigurationFactory is the seam contract that decouples database-engine-specific NHibernate configuration bootstrap from the rest of the unit-of-work/repository stack. Consumers wiring up dependency injection construct an IUnitOfWorkFactory with a matching IConfigurationFactory implementation (OracleConfigurationFactory or SqlServerConfigurationFactory) so the unit-of-work factory never has to know which database engine it targets.
Purpose¶
- Defines the single operation (
GetConfiguration) that builds or retrieves a cached, engine-specific NHibernateConfiguration/ISessionFactoryfor a connection string. - Allows
UnitOfWorkFactoryBaseand its subclasses to remain engine-agnostic — they depend only on this interface, not onOracleConfigurationFactory/SqlServerConfigurationFactorydirectly.
Context¶
- Namespace:
SAIF.Data.NHibernate - Assembly/package:
SAIF.Framework.Data.NHibernate
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| GetConfiguration | PersistenceConfiguration GetConfiguration(string connection, int batchSize, bool showSql) |
Builds (or returns a cached) PersistenceConfiguration — an NHibernate Configuration plus its serialized-config file path — for the given connection string, batch size, and show-SQL flag. |
Behavioral notes¶
- Implementations (
ConfigurationFactoryBaseand its subclasses) cache built configurations in aConcurrentDictionary<string, PersistenceConfiguration>keyed by connection string, so repeated calls with the same connection string are cheap after the first.*
Constraints and usage notes¶
- Implementers must supply the engine-specific pieces (
GetNewConfiguration,GetConfigurationFileName) thatConfigurationFactoryBasedelegates to when there is no cached or serialized configuration available.
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
Interfaces/IConfigurationFactory.csFactories/ConfigurationFactoryBase.cs