/// <summary> /// Use the NHibernate backed saga persister implementation. /// SagaData classes are automatically mapped using Fluent NHibernate conventions /// and there persistence schema is automatically generated if requested. /// </summary> /// <param name="config"></param> /// <param name="nhibernateProperties"></param> /// <param name="autoUpdateSchema"></param> /// <returns></returns> public static Configure NHibernateSagaPersister(this Configure config, IDictionary <string, string> nhibernateProperties, bool autoUpdateSchema) { if (!Sagas.Impl.Configure.SagasWereFound) { return(config); //no sagas - don't need to do anything } if (nhibernateProperties == null) { throw new InvalidOperationException("No properties configured for NHibernate. Check that you have a configuration section called 'NHibernateSagaPersisterConfig'."); } var builder = new SessionFactoryBuilder(Configure.TypesToScan); var sessionFactory = builder.Build(nhibernateProperties, autoUpdateSchema); if (sessionFactory == null) { throw new InvalidOperationException("Could not create session factory for saga persistence."); } config.Configurer.RegisterSingleton <ISessionFactory>(sessionFactory); config.Configurer.ConfigureComponent <SagaPersister>(DependencyLifecycle.InstancePerCall); config.NHibernateUnitOfWork(); return(config); }