Skip to content

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 NHibernate Configuration/ISessionFactory for a connection string.
  • Allows UnitOfWorkFactoryBase and its subclasses to remain engine-agnostic — they depend only on this interface, not on OracleConfigurationFactory/SqlServerConfigurationFactory directly.

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 (ConfigurationFactoryBase and its subclasses) cache built configurations in a ConcurrentDictionary<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) that ConfigurationFactoryBase delegates 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.cs
  • Factories/ConfigurationFactoryBase.cs