public static IInversionContainer setupHibernate(this IInversionContainer container, IConnectionsSource connectionsSource, params PersistenceModel[] models) { try { var nhib = typeof(NHibernate.ISession).Assembly; } catch (Exception ex) { //NOTE:assume that NHibernate not supplied at all!!!! it's not mistake - people just don't want use ORM but app call this method return container; } if (connectionsSource != null) { container.ensureService(connectionsSource, "default.connectionssource"); } else { container.ensureService<IConnectionsSource, DefaultConnectionsSource>("default.connectionssource"); } if (null != models) { var i = 0; foreach (var model in models) { i++; container.ensureService(model, "model." + model.GetType().Name + "." + i); } } container .ensureService<IConfigurationProvider, DefaultConfigurationProvider> ("default.hibernate.configuration.provider") .ensureService<ISessionFactoryProvider, DefaultSessionFactoryProvider> ("default.hibernate.factory.provider") .ensureService<IStorage, HibernateStorage>("default.hibernate.storage") .AddTransient("default.temporary.current.session", typeof(TemporaryTransactionSession)) .AddTransient("http.session.clear", typeof(HttpContextSessionCleaner)) .AddTransient("default.hibernate.applyer", typeof(HibernatePropertyApplyer)) .AddTransient("default.hibernate.applyer.impl", typeof(DefaultHibernatePropertyApplyerImpl)) ; return container; }
public static IInversionContainer setupHibernate(this IInversionContainer container, IConnectionsSource connectionsSource) { //if (checkexistence && !hasnhib()) return container; return setupHibernate(container, connectionsSource, null); }