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


C# Configuration.SetListener方法代码示例

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


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

示例1: Configure

 private static void Configure()
 {
     cfg = new Configuration();
     //cfg.SetProperty("hibernate.search.default.directory_provider", typeof(RAMDirectoryProvider).AssemblyQualifiedName);
     cfg.SetProperty("hibernate.search.default.directory_provider", typeof(FSDirectoryProvider).AssemblyQualifiedName);
     cfg.SetProperty(NHibernate.Search.Environment.AnalyzerClass, typeof(StopAnalyzer).AssemblyQualifiedName);
     cfg.SetListener(NHibernate.Event.ListenerType.PostUpdate, new FullTextIndexEventListener());
     cfg.SetListener(NHibernate.Event.ListenerType.PostInsert, new FullTextIndexEventListener());
     cfg.SetListener(NHibernate.Event.ListenerType.PostDelete, new FullTextIndexEventListener());
     cfg.Configure();
     sf = cfg.BuildSessionFactory();
 }
开发者ID:tzsage,项目名称:LuceneExamples,代码行数:12,代码来源:Program.cs

示例2: TestEvent2

        public void TestEvent2()
        {
            var config = new NHibernate.Cfg.Configuration();
            config.Configure();
            config.DataBaseIntegration(db =>
            {
                db.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
            });

            config.SetListener(ListenerType.PreUpdate, new TestUpdateEventListener());

            config.AddDeserializedMapping(InternalHelper.GetAllMapper(), "Models");

            var factory = config.BuildSessionFactory();

            using (var session = factory.OpenSession())
            {
                session.Save(new Message() { Content = "Message1", Creator = "Leoli_EventTest" });
                session.Flush();
            }

            using (var session = factory.OpenSession())
            {
                var message = session.Get<Message>(1);
                message.Content = "Message_Leoli2";
                session.Save(message);
                session.Flush();
                Assert.AreEqual(message.LastEditor, "Leoli_Update_Event");
            }
        }
开发者ID:leejulee,项目名称:NhibernateTest,代码行数:30,代码来源:UnitTestEvent.cs

示例3: CreateConfiguration

        public static Configuration CreateConfiguration()
        {
            // XML-Files
            Configuration config = new Configuration();
            config.AddAssembly(Assembly.GetExecutingAssembly());

            // Event-Listener
            config.SetListeners(ListenerType.PostInsert, new[] { new FullTextIndexEventListener() });
            config.SetListeners(ListenerType.PostUpdate, new[] { new FullTextIndexEventListener() });
            config.SetListeners(ListenerType.PostDelete, new[] { new FullTextIndexEventListener() });
            config.SetListener(ListenerType.PostCollectionRecreate, new FullTextIndexCollectionEventListener());
            config.SetListener(ListenerType.PostCollectionRemove, new FullTextIndexCollectionEventListener());
            config.SetListener(ListenerType.PostCollectionUpdate, new FullTextIndexCollectionEventListener());

            return config;
        }
开发者ID:pweibel,项目名称:DinX,代码行数:16,代码来源:PersistenceManager.cs

示例4: Configure

		protected override void Configure(Configuration configuration)
		{
			configuration.SetProperty(Environment.UseSecondLevelCache, "false");
			configuration.SetProperty(Environment.UseQueryCache, "false");
			configuration.SetProperty(Environment.CacheProvider, null);
			configuration.SetListener(ListenerType.PostCommitDelete, new PostCommitDelete());
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:7,代码来源:Fixture.cs

示例5: Configure

        public NHibernate.Cfg.Configuration Configure()
        {
            var config = new NHibernate.Cfg.Configuration();
            config.SetProperty(Environment.ReleaseConnections, "on_close")
                .SetProperty(Environment.Dialect, typeof (NHibernate.Spatial.Dialect.MsSql2008GeographyDialect).AssemblyQualifiedName)
                .SetProperty(Environment.ConnectionDriver, typeof (NHibernate.Driver.SqlClientDriver).AssemblyQualifiedName);

            var modelMapper = new ModelMapper(new ModelInspector());
            modelMapper.AddMappings(typeof(ModelInspector).Assembly.GetExportedTypes());

            var mapping = modelMapper.CompileMappingForAllExplicitlyAddedEntities();
            config.AddMapping(mapping);

            config.SetListener(NHibernate.Event.ListenerType.PostUpdate, new FullTextIndexEventListener());
            config.SetListener(NHibernate.Event.ListenerType.PostInsert, new FullTextIndexEventListener());
            config.SetListener(NHibernate.Event.ListenerType.PostDelete, new FullTextIndexEventListener());

            return config;
        }
开发者ID:techsavy,项目名称:AtYourService,代码行数:19,代码来源:NHibernateConfigurator.cs

示例6: 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

示例7: SetListener

 public static void SetListener(Configuration configure)
 {
     configure.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener());
     configure.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener());
     configure.SetListener(ListenerType.PostDelete, new FullTextIndexEventListener());
     configure.SetListener(ListenerType.PostCollectionRecreate, new FullTextIndexCollectionEventListener());
     configure.SetListener(ListenerType.PostCollectionRemove, new FullTextIndexCollectionEventListener());
     configure.SetListener(ListenerType.PostCollectionUpdate, new FullTextIndexCollectionEventListener());
 }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:9,代码来源:SearchTestCase.cs

示例8: AddSearchListeners

 private void AddSearchListeners(Configuration cfg)
 {
     cfg.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener());
     cfg.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener());
     cfg.SetListener(ListenerType.PostDelete, new FullTextIndexEventListener());
     cfg.SetListener(ListenerType.PostCollectionRecreate, new FullTextIndexCollectionEventListener());
     cfg.SetListener(ListenerType.PostCollectionRemove, new FullTextIndexCollectionEventListener());
     cfg.SetListener(ListenerType.PostCollectionUpdate, new FullTextIndexCollectionEventListener());
 }
开发者ID:farihan,项目名称:ContosoAngular,代码行数:9,代码来源:SearchConfiguration.cs

示例9: CreateSessionFactory

        private static ISessionFactory CreateSessionFactory()
        {
            var cfg = new Configuration()
                .SetInterceptor(new DontHurtMe())
                .SetProperty(NHibernate.Cfg.Environment.Hbm2ddlAuto, "update")
                .SetProperty(NHibernate.Cfg.Environment.DefaultBatchFetchSize, "10")
                .DataBaseIntegration(db =>
                {
                    db.ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=nh;Integrated Security=SSPI";
                    db.Dialect<MsSql2008Dialect>();
                })
                .AddAssembly(Assembly.GetExecutingAssembly());

            cfg
                .SetListener(ListenerType.PreUpdate, new AuditListener());

            return cfg.BuildSessionFactory();
        }
开发者ID:ronsher,项目名称:NHibernate-London-May,代码行数:18,代码来源:Global.asax.cs

示例10: SetListener

 private void SetListener(Configuration config, object listener)
 {
     if (listener == null)
         throw new ArgumentNullException("listener");
     foreach (var intf in listener.GetType().GetInterfaces())
         if (ListenerDict.ContainsKey(intf))
             foreach (var t in ListenerDict[intf])
                 config.SetListener(t, listener);
 }
开发者ID:osdezwart,项目名称:SolrNet,代码行数:9,代码来源:CfgHelper.cs

示例11: Apply

		public void Apply(Configuration cfg)
		{
			cfg.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener());
			cfg.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener());
			cfg.SetListener(ListenerType.PostDelete, new FullTextIndexEventListener());
		}
开发者ID:najeraz,项目名称:Fluent-NHibernate-Search,代码行数:6,代码来源:DefaultListenerConfiguration.cs

示例12: Configure

		protected override void Configure(Configuration cfg)
		{
			cfg.SetListener(ListenerType.PreInsert, new PreSaveDoVeto());
		}
开发者ID:hoangduc007,项目名称:nhibernate-core,代码行数:4,代码来源:Fixture.cs

示例13: Main

        private static void Main(string[] args)
        {
            XmlConfigurator.Configure(new FileInfo("nhprof.log4net.config"));

            Configuration cfg = new Configuration()
                .Configure("nhibernate.cfg.xml");

            cfg.SetProperty("hibernate.search.default.directory_provider",
                            typeof (FSDirectoryProvider).AssemblyQualifiedName);
            cfg.SetProperty(Environment.AnalyzerClass,
                            typeof (StopAnalyzer).AssemblyQualifiedName);

            cfg.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener());
            cfg.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener());
            cfg.SetListener(ListenerType.PostDelete, new FullTextIndexEventListener());

            using (new ConsoleColorer("nhibernate"))
                new SchemaExport(cfg).Execute(true, true, false, true);

            ISessionFactory factory = cfg.BuildSessionFactory();
            using (IFullTextSession s = Search
                .CreateFullTextSession(factory.OpenSession()))
            using (ITransaction tx = s.BeginTransaction())
            {
                s.PurgeAll(typeof (Employee));
                s.PurgeAll(typeof (Salary));

                var salary = new Salary
                                 {
                                     Name = "MinPay",
                                     HourlyRate = 22m
                                 };
                var emp = new Employee
                              {
                                  Name = "ayende",
                                  Salary = salary
                              };
                s.Save(salary);
                s.Save(emp);


                tx.Commit();
            }

            Thread.Sleep(1500);
            Console.Clear();
            using (IFullTextSession s = Search.CreateFullTextSession(factory.OpenSession()))
            using (ITransaction tx = s.BeginTransaction())
            {
                var employees = s.CreateFullTextQuery<Employee>("Name", "a*")
                    .List<Employee>();
                foreach (Employee employee in employees)
                {
                    Console.WriteLine("Employee: " + employee.Name);
                    Console.WriteLine("Salary: {0} - {1:C}",
                                      employee.Salary.Name,
                                      employee.Salary.HourlyRate);
                }

                var salaries = s.CreateFullTextQuery<Salary>("HourlyRate:[20 TO 25]")
                    .List<Salary>();
                foreach (var salary in salaries)
                {
                    Console.WriteLine("Salaray: {0} - {1:C}", salary.Name, salary.HourlyRate);
                }

                tx.Commit();
            }
        }
开发者ID:JackWangCUMT,项目名称:rhino-tools,代码行数:69,代码来源:Program.cs

示例14: AddAuditor

 private static void AddAuditor(Configuration config)
 {
     config.SetListener(ListenerType.PostUpdate, new AuditUpdateListener());
 }
开发者ID:DarrellMozingo,项目名称:Blog,代码行数:4,代码来源:Program.cs

示例15: GetSessionFactory

        private ISessionFactory GetSessionFactory()
        {
            Configuration = new Configuration().Configure("NHibernate.config");
            string path = Environment.CurrentDirectory + "\\TestDB.db3";
            Configuration.Properties["connection.connection_string"] = "Data Source=" + path + ";Version=3;";

            FluentConfiguration fluentConfiguration = Fluently.Configure(Configuration);
            Configuration.SetListener(ListenerType.Delete, new MyDeleteEventListener());
            Configuration.SetListener(ListenerType.Load, new MyLoadEventListener());
            InitMapping(fluentConfiguration);

            var sf= fluentConfiguration.BuildSessionFactory();
            //fluentConfiguration.Mappings(x => x.AutoMappings.ExportTo(@"D:\Temp"));
            CreateHighLowTable(Configuration, new HiloTable() { TableNameColumn = PrimaryKeyConvention.TableColumnName, Name = PrimaryKeyConvention.NHibernateHiLoIdentityTableName, NextHiColumn = PrimaryKeyConvention.NextHiValueColumnName });

            return sf;
        }
开发者ID:akhuang,项目名称:NHibernateTest,代码行数:17,代码来源:NHibernateHelper.cs


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