本文整理汇总了C#中Configuration.AddAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddAssembly方法的具体用法?C# Configuration.AddAssembly怎么用?C# Configuration.AddAssembly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.AddAssembly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder
.Register<NHibernateImplementationTypeChecker>(
c => new NHibernateImplementationTypeChecker(
c.Resolve<Func<IEnumerable<IImplementationTypeChecker>>>()))
.As<INHibernateImplementationTypeChecker>()
.As<IImplementationTypeChecker>()
.InstancePerDependency();
builder
.Register<NHibernateActionsManager>(
c => new NHibernateActionsManager(
c.Resolve<ILifetimeScope>(),
c.Resolve<IDeploymentRestrictor>()))
.As<INHibernateActionsManager>()
.InstancePerLifetimeScope();
builder
.Register<ISessionFactory>(
c => {
var zetboxConfig = c.Resolve<ZetboxConfig>();
var result = new Configuration();
var connectionString = zetboxConfig.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey);
result.Properties["dialect"] = connectionString.DatabaseProvider;
result.Properties["connection.connection_string"] = connectionString.ConnectionString;
result.Properties["max_fetch_depth"] = "1"; // keep SQL statements small
return result
.AddAssembly(typeof(NHibernateModule).Assembly)
.BuildSessionFactory();
})
.SingleInstance();
builder
.Register<ISession>(
(c, p) => {
var result = c.Resolve<ISessionFactory>().OpenSession(c.Resolve<IInterceptor>());
Logging.Log.DebugFormat("Created ISession: {0}", result.GetHashCode());
return result;
})
.OnRelease(s => Logging.Log.DebugFormat("Disposed ISession: {0}", s.GetHashCode()))
// TODO: reconsider this configuration
// using IPD makes it safer, but requires passing the session manually
// on the other hand, the session should never escape the data context
.InstancePerDependency();
}
示例2: Load
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder
.Register<NHibernateImplementationTypeChecker>(
c => new NHibernateImplementationTypeChecker(
c.Resolve<Func<IEnumerable<IImplementationTypeChecker>>>()))
.As<INHibernateImplementationTypeChecker>()
.As<IImplementationTypeChecker>()
.InstancePerDependency();
builder
.Register<NHibernateActionsManager>(
c => new NHibernateActionsManager(
c.Resolve<ILifetimeScope>(),
c.Resolve<IEnumerable<ImplementorAssembly>>()))
.As<INHibernateActionsManager>()
.InstancePerLifetimeScope();
builder
.Register<ISessionFactory>(
c => {
var zetboxConfig = c.Resolve<ZetboxConfig>();
using (Logging.Log.InfoTraceMethodCall("Init NH Session Factory"))
{
var result = new Configuration();
var connectionString = zetboxConfig.Server.GetConnectionString(Zetbox.API.Helper.ZetboxConnectionStringKey);
result.Properties["dialect"] = connectionString.DatabaseProvider;
result.Properties["connection.connection_string"] = connectionString.ConnectionString;
result.Properties["max_fetch_depth"] = "1"; // keep SQL statements small
return result
.AddAssembly(typeof(NHibernateModule).Assembly)
.BuildSessionFactory();
}
})
.SingleInstance();
}
示例3: CreateNHibernateConfiguration
protected virtual Configuration CreateNHibernateConfiguration( Assembly[] inputAssemblies, ProxyGeneratorOptions options )
{
Configuration nhibernateConfiguration = new Configuration();
//nhibernateConfiguration.AddProperties(GetDefaultNHibernateProperties(options));
nhibernateConfiguration.SetProperties(GetDefaultNHibernateProperties(options));
foreach (Assembly inputAssembly in inputAssemblies)
{
nhibernateConfiguration.AddAssembly(inputAssembly);
}
return nhibernateConfiguration;
}