本文整理汇总了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>();
});
}
示例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;
});
}
示例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));
}
}
示例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();
}
示例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);
}