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


C# NHibernate.Cfg.Configuration.SetListener方法代码示例

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


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

示例1: AddEventListeners

        private static void AddEventListeners(Configuration config)
        {
            config.SetListener(ListenerType.PreInsert, new SetCreationDateListener());
            config.SetListener(ListenerType.PreUpdate, new SetUpdateDateListener());

            //SearchEngine Index update, ie:ElasticSearch
            config.SetListener(ListenerType.PostInsert, new UpdateIndexListener());
            config.SetListener(ListenerType.PostUpdate, new UpdateIndexListener());
        }
开发者ID:daparadoks,项目名称:ParadoxProperty,代码行数:9,代码来源:PersistenceFacility+.cs

示例2: ShouldAppendToExistingListeners

        public void ShouldAppendToExistingListeners()
        {
            var cfg = new NHibernate.Cfg.Configuration();
            if (TestConfigurationHelper.hibernateConfigFile != null)
                cfg.Configure(TestConfigurationHelper.hibernateConfigFile);
            cfg.SetListener(ListenerType.PreInsert, new ListenersStub());
            cfg.SetListener(ListenerType.PreUpdate, new ListenersStub());
            var nhvc = new XmlConfiguration();
            nhvc.Properties[Environment.ApplyToDDL] = "true";
            nhvc.Properties[Environment.AutoregisterListeners] = "true";
            nhvc.Properties[Environment.ValidatorMode] = "UseAttribute";

            ValidatorInitializer.Initialize(cfg);
            Assert.That(cfg.EventListeners.PreInsertEventListeners.Length, Is.EqualTo(2));
            Assert.That(cfg.EventListeners.PreInsertEventListeners[1], Is.TypeOf<ValidatePreInsertEventListener>());
            Assert.That(cfg.EventListeners.PreUpdateEventListeners.Length, Is.EqualTo(2));
            Assert.That(cfg.EventListeners.PreUpdateEventListeners[1], Is.TypeOf<ValidatePreUpdateEventListener>());
        }
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:18,代码来源:ValidatorInitializerFixture.cs

示例3: AddEventListeners

 private void AddEventListeners(Configuration config)
 {
     config.SetListener(ListenerType.PreInsert, new SetCreationDateListener());
     config.SetListener(ListenerType.Delete, new DeleteListener());
 }
开发者ID:umutyenilmis,项目名称:SignalR-Demo,代码行数:5,代码来源:PersistenceFacility.cs

示例4: RegisterListeners

		/// <summary>
		/// Registers the listeners.
		/// </summary>
		/// <param name="cfg">The CFG.</param>
		/// <param name="facilityConfig">The facility config.</param>
		protected void RegisterListeners(Configuration cfg, IConfiguration facilityConfig)
		{
			if (facilityConfig == null) return;

			foreach (IConfiguration item in facilityConfig.Children)
			{
				String eventName = item.Attributes["event"];
				String typeName = item.Attributes["type"];

				if (!Enum.IsDefined(typeof (ListenerType), eventName))
					throw new ConfigurationErrorsException("An invalid listener type was specified.");

				Type classType = Type.GetType(typeName);

				//if (classType == null)
				//    throw new ConfigurationErrorsException("The full type name of the listener class must be specified.");

				var listenerType = (ListenerType) Enum.Parse(typeof (ListenerType), eventName);
				object listenerInstance = Activator.CreateInstance(classType);

				cfg.SetListener(listenerType, listenerInstance);
			}
		}
开发者ID:hconceicao,项目名称:Castle.Facilities.NHibernateIntegration3,代码行数:28,代码来源:DefaultConfigurationBuilder.cs

示例5: BuildFactory

        private ISessionFactory BuildFactory(List<Assembly> fluentMappingAssemblies)
        {
            try
            {
                var connectionString = ConnectionStringOverride ?? ConfigurationManager.AppSettings["ELEVATECONNECTION"];

                Debug.WriteLine("Configuring session factory to connect to " + connectionString);

                configuration = Fluently.Configure()
                    .Database
                    (
                        MsSqlConfiguration.MsSql2005
                                          .ConnectionString(c => c.Is(connectionString))
                                          .CurrentSessionContext(NHibernateConstants.NHibernateWebSessonContext)

                    )
                    .Mappings(m => fluentMappingAssemblies.ForEach(a => m.FluentMappings.AddFromAssembly(a)))
                    .ExposeConfiguration(c => c.SetProperty("generate_statistics", "true"))
                    .ExposeConfiguration(c => c.SetProperty("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"))
                    .ExposeConfiguration(c => c.SetProperty("adonet.batch_size", "1"))
                    .BuildConfiguration();

                configuration.SetListener(ListenerType.PreUpdate, new AuditEventListener(LocalContext.Current));
                configuration.SetListener(ListenerType.PreInsert, new AuditEventListener(LocalContext.Current));

                _sessionFactory = configuration.BuildSessionFactory();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }

            return _sessionFactory;
        }
开发者ID:mickdelaney,项目名称:Infrastructure,代码行数:35,代码来源:SessionManager.cs


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