當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。