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


C# Configuration.SetInterceptor方法代码示例

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


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

示例1: BuildSchema

 private void BuildSchema(Configuration config)
 {
     SchemaExport schema = new SchemaExport(config);
     schema.Drop(this._criaScript, this._exportaScriptBD);
     schema.Create(this._criaScript, this._exportaScriptBD);
     config.SetInterceptor(new SqlStatementInterceptor());
 }
开发者ID:RMedeirosCosta,项目名称:eimbo,代码行数:7,代码来源:NHibernateHelper.cs

示例2: GetConfiguration

        private Configuration GetConfiguration()
        {
            var config = new Configuration().Configure();
            this.mappingAssemblies.ForEach(ma => config.AddAssembly(ma));
            config.SetInterceptor(new SqlQueryInterceptor());

            return config;
        }
开发者ID:nanovazquez,项目名称:nhibernate-inverse-cascade-samples,代码行数:8,代码来源:NHibernateSessionFactory.cs

示例3: TemporaryDatabase

 /// <summary>
 /// Initializes a new instance of the <see cref="TemporaryDatabase"/> class.
 /// </summary>
 public TemporaryDatabase()
 {
     _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.AddAssembly(typeof(IRepository).Assembly);
     _sessionFactory = configuration.BuildSessionFactory();
     var upgradeManager = new DatabaseManager(_database.ConnectionString);
     upgradeManager.PerformUpgrade();
 }
开发者ID:PaulStovell,项目名称:bindable,代码行数:18,代码来源:TemporaryDatabase.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: GetConfiguration

 public Configuration GetConfiguration()
 {
     if (m_Configuration == null)
     {
         lock (m_Locker)
         {
             if (m_Configuration == null)
             {
                 m_Configuration = Configuration;
                 m_Configuration.SetInterceptor(Interceptor);
                 foreach (IRegisterEventListener registerListener in RegisterEventListeners)
                 {
                     registerListener.Register(m_Configuration);
                 }
             }
         }
     }
     return m_Configuration;
 }
开发者ID:jandppw,项目名称:ppwcode-recovered-from-google-code,代码行数:19,代码来源:NhConfigurationBase.cs

示例6: BuildConfiguration

        public static Configuration BuildConfiguration(string mappingAssembliesFile, string hibernateConfigurationFile, string applicationDirectory, params IInterceptor[] interceptors)
        {
            var mapper = BuildModelMapper(mappingAssembliesFile, applicationDirectory);
            var cfg = new Configuration();

            if (File.Exists(hibernateConfigurationFile))
            {
                cfg.Configure(hibernateConfigurationFile);
            }

            if (mapper != null)
            {
                cfg.AddDeserializedMapping(mapper.CompileMappingForAllExplicitlyAddedEntities(), string.Empty);
            }

            foreach (var interceptor in interceptors)
            {
                cfg.SetInterceptor(interceptor);
            }

            return cfg;
        }
开发者ID:juanonsoftware,项目名称:gdnet-webframework,代码行数:22,代码来源:ConfigurationAssistant.cs

示例7: Configure

		protected override void Configure(Configuration configuration)
		{
			configuration.SetInterceptor(new ProxyInterceptor());
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:4,代码来源:InterceptorDynamicEntity.cs

示例8: BuildSessionFactory

        public static NHibernate.ISessionFactory BuildSessionFactory(bool useUnitTest = false)
        {
            var mapper = new NHibernate.Mapping.ByCode.ConventionModelMapper();


            mapper.IsEntity((t, declared) => t.Namespace == "Domain");

            mapper.BeforeMapClass += mapper_BeforeMapClass;
            mapper.BeforeMapProperty += mapper_BeforeMapProperty;
            mapper.BeforeMapManyToOne += mapper_BeforeMapManyToOne;            
            mapper.BeforeMapBag += mapper_BeforeMapBag;

            var cfg = new NHibernate.Cfg.Configuration();



            // .DatabaseIntegration! Y U EXTENSION METHOD?!
            cfg.DataBaseIntegration(c =>
            {
                var cs = System.Configuration.ConfigurationManager.ConnectionStrings["TheSpaConnection"].ConnectionString;


                // SQL Server
                c.Driver<NHibernate.Driver.SqlClientDriver>();
                c.Dialect<NHibernate.Dialect.MsSql2008Dialect>();
                c.ConnectionString = "Server=.;Database=SpaArchitectureMvp;Trusted_Connection=True";

                //// PostgreSQL                
                //c.Driver<NHibernate.Driver.NpgsqlDriver>();
                //c.Dialect<NHibernate.Dialect.PostgreSQLDialect>();
                //c.ConnectionString = cs;

                if (useUnitTest)
                {
                    c.LogSqlInConsole = true;
                    c.LogFormattedSql = true;
                }
            });


            System.Collections.Generic.IEnumerable<System.Type> entities = typeof(Domain.PersonDomain.Person).Assembly.GetExportedTypes()
                .Where(x => !(x.IsAbstract && x.IsSealed)); // exclude static 



            NHibernate.Cfg.MappingSchema.HbmMapping mapping = mapper.CompileMappingFor(entities);

            cfg.AddMapping(mapping);


            // http://www.ienablemuch.com/2013/06/multilingual-and-caching-on-nhibernate.html
            //var filterDef = new NHibernate.Engine.FilterDefinition("lf", /*default condition*/ null,
            //                                           new Dictionary<string, NHibernate.Type.IType>
            //                                                           {
            //                                                               { "LanguageCultureCode", NHibernate.NHibernateUtil.String}
            //                                                           }, useManyToOne: false);
            //cfg.AddFilterDefinition(filterDef);



            cfg.Cache(x =>
            {
                // SysCache is not stable on unit testing
                if (!useUnitTest)
                {
                    x.Provider<NHibernate.Caches.SysCache.SysCacheProvider>();

                    // I don't know why SysCacheProvider is not stable on simultaneous unit testing, 
                    // might be SysCacheProvider is just giving one session factory, so simultaneous test see each other caches
                    // This solution doesn't work: http://stackoverflow.com/questions/700043/mstest-executing-all-my-tests-simultaneously-breaks-tests-what-to-do                    
                }
                else
                {
                    // This is more stable in unit testing
                    x.Provider<NHibernate.Cache.HashtableCacheProvider>();
                }


                // http://stackoverflow.com/questions/2365234/how-does-query-caching-improves-performance-in-nhibernate

                // Need to be explicitly turned on so the .Cacheable directive on Linq will work:                    
                x.UseQueryCache = true;
            });



            if (useUnitTest)
                cfg.SetInterceptor(new NHSQLInterceptor());



            //new NHibernate.Tool.hbm2ddl.SchemaUpdate(cfg).Execute(useStdOut: false, doUpdate: true);


            //using (var file = new System.IO.FileStream(@"c:\x\ddl.txt",
            //       System.IO.FileMode.Create,
            //       System.IO.FileAccess.ReadWrite))
            //using (var sw = new System.IO.StreamWriter(file))
            //{
            //    new SchemaUpdate(cfg)
//.........这里部分代码省略.........
开发者ID:MichaelBuen,项目名称:DemoSpaArchitectureMvp,代码行数:101,代码来源:Mapper.cs

示例9: SetInterceptors

 private static void SetInterceptors(Configuration cfg)
 {
     cfg.SetInterceptor(new SqlStatementInterceptor());
 }
开发者ID:sam-zhou,项目名称:lynex.ocr,代码行数:4,代码来源:NHibernateHelper.cs

示例10: Configure

		protected override void Configure(Configuration configuration)
		{
			configuration.SetInterceptor(new EntityNameInterceptor());
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:4,代码来源:TuplizerDynamicEntity.cs

示例11: CreateNHibernateConfiguration

 private static Configuration CreateNHibernateConfiguration(IUnityContainer container)
 {
     var cfg = new Configuration().Configure();
     cfg.SetInterceptor(new BuildWithProviderInterceptor(container.Resolve<IServiceProvider>(), cfg.ClassMappings));
     return cfg;
 }
开发者ID:tmont,项目名称:portoa,代码行数:6,代码来源:EnableNHibernate.cs

示例12: CreateSessionFactory

        /// <summary>
        /// The session factory.
        /// </summary>
        /// <returns>A session factory.</returns>
        protected override ISessionFactory CreateSessionFactory()
        {
            ISessionFactory factory;
            if (!NHibernateEntityContext.sessionFactories.TryGetValue(ENABLED_ENVIRONMENT_MARKER, out factory))
            {
                IPersistenceConfigurer persistence = null;

                switch (ApplicationModelConfiguration.Configuration.Server.Environments.GetEnabledEnvironment().DataSource.Dialect)
                {
                    case "MsSql2005":
                        {
                            string connectionString = ApplicationModelConfiguration.Configuration.Server.Environments.GetEnabledEnvironment().DataSource.ConnectionString;
                            persistence = MsSqlConfiguration.MsSql2005.ConnectionString(connectionString);
                        }
                        break;

                    case "MsSql2008":
                        {
                            string connectionString = ApplicationModelConfiguration.Configuration.Server.Environments.GetEnabledEnvironment().DataSource.ConnectionString;
                            persistence = MsSqlConfiguration.MsSql2008.ConnectionString(connectionString);
                        }
                        break;

                    case "SQLite":
                        {
                            string connectionString = ApplicationModelConfiguration.Configuration.Server.Environments.GetEnabledEnvironment().DataSource.ConnectionString;
                            persistence = SQLiteConfiguration.Standard.ConnectionString(connectionString);
                        }
                        break;

                    default:
                        throw new NotImplementedException();
                }

                string mappingAssembly = ApplicationModelConfiguration.Configuration.Server.Environments.GetEnabledEnvironment().Settings[MAPPING_ASSEMBLY_IDENTIFIER].Value;

                Configuration configuration = new Configuration();
                configuration.SetInterceptor(new NhibernateSqlInterceptor());

                FluentConfiguration fluentConfiguration =
                    Fluently.Configure(configuration)
                        .Database(persistence)
                        .Mappings(mappings => mappings.FluentMappings.AddFromAssembly(Assembly.Load(mappingAssembly)));

                NHibernateEntityContext.sessionFactories[ENABLED_ENVIRONMENT_MARKER] = factory = fluentConfiguration.BuildSessionFactory();
            }

            return factory;
        }
开发者ID:petervyvey,项目名称:membrane,代码行数:53,代码来源:FluentNHibernateEntityContext.cs

示例13: CreateConfiguration

        private static Configuration CreateConfiguration()
        {
            var cfg = new Configuration();
            //cfg.SetNamingStrategy(new NamingConvention());
            cfg.DataBaseIntegration(properties =>
            {
                //properties.SchemaAction = SchemaAutoAction.Validate;
                properties.Dialect<NHibernate.Dialect.MsSql2008Dialect>();
                properties.ConnectionStringName = Environment.MachineName;
            });
            cfg.AddAssembly(Assembly.GetExecutingAssembly());
            cfg.SetInterceptor(new DontMakeMeCRY());

            cfg.SetProperty(
                NHibernate.Cfg.Environment.DefaultBatchFetchSize,
                "25");
            return cfg;
        }
开发者ID:ayende,项目名称:course-jul-25,代码行数:18,代码来源:NHibernateController.cs


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