/// <summary>
        /// 
        /// </summary>
        /// <param name="config"></param>
        protected override void PostProcessConfiguration(Configuration config)
        {
            if (FluentNhibernateMappingAssemblies != null)
            {
                foreach (var assemblyName in FluentNhibernateMappingAssemblies)
                {
                    config.AddMappingsFromAssembly(Assembly.Load(assemblyName));
                }
            }

            config.Properties.Add("nhibernate.envers.Diversia_with_modified_flag", "true");
                //log property data for revisions
            config.IntegrateWithEnvers(new AttributeConfiguration());
            config.SetListener(ListenerType.PreInsert, new DiversiaAuditEventListener());
            config.SetListener(ListenerType.PreUpdate, new DiversiaAuditEventListener());
            config.SetListener(ListenerType.PreDelete, new DiversiaAuditEventListener());
            config.SetListener(ListenerType.PreCollectionRecreate, new DiversiaAuditEventListener());
            config.SetListener(ListenerType.PreCollectionUpdate, new DiversiaAuditEventListener());
            config.SetListener(ListenerType.PreCollectionRemove, new DiversiaAuditEventListener());
            config.Cache(c =>
            {
                c.UseMinimalPuts = true;
                c.UseQueryCache = true;
                c.Provider<SysCacheProvider>();
            });
        }
        protected override void Context()
        {
            base.Context();

            IDictionary<string, string> properties = new Dictionary<string, string>
             	{
             		{"connection.driver_class", "NHibernate.Driver.SQLite20Driver"},
             		{"dialect", "NHibernate.Dialect.SQLiteDialect"},
             		{"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
             		{"connection.connection_string", @"Data Source=:memory:;Version=3;New=True;"},
             		{"connection.release_mode", "on_close"}
             	};

            NHibernateConfig config
                = new NHibernateConfig(() =>
                                       	{
                                       		var cfg = new Configuration().Configure()
                                                .SetProperties(properties);
                                            cfg.AddMappingsFromAssembly(typeof(WidgetMap).Assembly);
                                       		return cfg;
                                       	}, _repositoryFactory, _uowStorage);

            UnitOfWork.Configure(config);
            UnitOfWork.Start(() =>
            {
                wasExecuted = true;
            });
        }
        /// <summary>
        /// This method will be called after the configuration is processed but before the session factory is created.  
        /// </summary>
        /// <param name="config"></param>
        protected override void PostProcessConfiguration(Configuration config)
        {
            base.PostProcessConfiguration(config);

            if (FluentNhibernateMappingAssemblies == null) return;
            foreach (string assemblyName in FluentNhibernateMappingAssemblies)
            {
                config.AddMappingsFromAssembly(Assembly.Load(assemblyName));
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestableDatabase"/> class.
 /// </summary>
 public TestableDatabase()
 {
     _database = new TemporarySqlDatabase();
     var configuration = new Configuration();
     configuration.SetInterceptor(new PostSaveInterceptor());
     configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
     configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
     configuration.SetProperty("connection.connection_string", _database.ConnectionString);
     configuration.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");
     configuration.SetProperty("show_sql", "true");
     configuration.AddMappingsFromAssembly(Cms.Domain.Properties.AssemblyReference.Assembly);
     _sessionFactory = configuration.BuildSessionFactory();
     var upgradeManager = new ApplicationDatabase(_database.ConnectionString);
     upgradeManager.PerformUpgrade();
 }
Ejemplo n.º 5
0
        protected void Application_Start()
        {
            var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Application"].ConnectionString;

            var configuration = new Configuration();
            configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
            configuration.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");
            configuration.SetProperty("connection.connection_string", connectionString);
            configuration.SetProperty("show_sql", "true");
            configuration.AddMappingsFromAssembly(Domain.Properties.AssemblyReference.Assembly);
            var sessionFactory = configuration.BuildSessionFactory();

            var htmlExtensionMethods = new[] {
                typeof(System.Web.Mvc.Html.FormExtensions),
                typeof(System.Web.Mvc.Html.InputExtensions),
                typeof(System.Web.Mvc.Html.LinkExtensions),
                typeof(System.Web.Mvc.Html.RenderPartialExtensions),
                typeof(System.Web.Mvc.Html.SelectExtensions),
                typeof(System.Web.Mvc.Html.TextAreaExtensions),
                typeof(System.Web.Mvc.Html.ValidationExtensions),
                typeof(NVelocityExtensions),
                typeof(HtmlExtensions)
            };

            ApplicationService.Current.RegisterAll<IController>(typeof(WikiController).Assembly, imp => imp.Name.ToLower(), Lifetime.Transient);
            ApplicationService.Current.RegisterAll<IRepository>(typeof(WikiRepository).Assembly, Lifetime.Transient);
            ApplicationService.Current.RegisterAll<IDiagnosticTest>(typeof(IDiagnosticTest).Assembly, Lifetime.Transient);
            ApplicationService.Current.Register<IApplicationDatabase>(() => new ApplicationDatabase(connectionString), Lifetime.Transient);
            ApplicationService.Current.Register<IDiagnosticService, DiagnosticService>(Lifetime.Transient);
            ApplicationService.Current.Register<ISession>(sessionFactory.OpenSession, Lifetime.PerWebRequest);
            ApplicationService.Current.Register<IViewEngine>(new NVelocityViewEngine(new [] { Properties.AssemblyReference.Assembly }, htmlExtensionMethods));

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(ApplicationService.Current.Resolve<IViewEngine>());
            ControllerBuilder.Current.SetControllerFactory(ApplicationService.Current.RegisterAndResolve<WindsorControllerFactory>(Lifetime.Singleton));
            RegisterRoutes(RouteTable.Routes);
        }