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


C# Configuration.AddAssembly方法代码示例

本文整理汇总了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();
        }
开发者ID:jrgcubano,项目名称:zetbox,代码行数:49,代码来源:Module.NHibernate.cs

示例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();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:39,代码来源:Module.NHibernate.cs

示例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;
        }
开发者ID:spib,项目名称:nhcontrib,代码行数:14,代码来源:CastleProxyGenerator.cs


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