当前位置: 首页>>代码示例>>C#>>正文


C# Configuration.AddMappingsFromAssembly方法代码示例

本文整理汇总了C#中NHibernate.Cfg.Configuration.AddMappingsFromAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddMappingsFromAssembly方法的具体用法?C# Configuration.AddMappingsFromAssembly怎么用?C# Configuration.AddMappingsFromAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.Cfg.Configuration的用法示例。


在下文中一共展示了Configuration.AddMappingsFromAssembly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostProcessConfiguration

        /// <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>();
            });
        }
开发者ID:truller2010,项目名称:Diversia,代码行数:30,代码来源:FluentNhibernateLocalSessionFactoryObject.cs

示例2: Context

        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;
            });
        }
开发者ID:derickbailey,项目名称:UnitOfWork,代码行数:28,代码来源:FluentNHibernateConfigurationSpecs.cs

示例3: PostProcessConfiguration

        /// <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));
            }
        }
开发者ID:BryanSandoval,项目名称:spikes-gitshah,代码行数:14,代码来源:FluentNhibernateLocalSessionFactoryObject.cs

示例4: TestableDatabase

 /// <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();
 }
开发者ID:PaulStovell,项目名称:bindable,代码行数:18,代码来源:TemporaryDatabase.cs

示例5: Application_Start

        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);
        }
开发者ID:PaulStovell,项目名称:bindable,代码行数:38,代码来源:Global.asax.cs


注:本文中的NHibernate.Cfg.Configuration.AddMappingsFromAssembly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。