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


C# Configuration.SetListeners方法代码示例

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


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

示例1: Contribute

 /// <summary>
 /// The actual contribution method.
 /// </summary>
 /// <param name="configuration">The configuration to be modified.</param>
 public override void Contribute(Configuration configuration)
 {
     if (configuration.Properties.ContainsKey("hibernate.search.analyzer"))
     {
         configuration.SetListeners(ListenerType.PostDelete, AddListenerTo(typeof(IPostDeleteEventListener), configuration.EventListeners.PostDeleteEventListeners));
         configuration.SetListeners(ListenerType.PostInsert, AddListenerTo(typeof(IPostInsertEventListener), configuration.EventListeners.PostInsertEventListeners));
         configuration.SetListeners(ListenerType.PostUpdate, AddListenerTo(typeof(IPostUpdateEventListener), configuration.EventListeners.PostUpdateEventListeners));
     }
 }
开发者ID:zhoufoxcn,项目名称:ActiveRecord,代码行数:13,代码来源:NHSearchContributor.cs

示例2: AppendTo

        public static void AppendTo(Configuration configuration)
        {
            configuration.SetListeners(
                ListenerType.PreInsert,
                configuration.EventListeners.PreInsertEventListeners.Concat(new IPreInsertEventListener[] { new ValidateEventListener() }).ToArray());

            configuration.SetListeners(
                ListenerType.PreUpdate,
                configuration.EventListeners.PreUpdateEventListeners.Concat(new IPreUpdateEventListener[] { new ValidateEventListener() }).ToArray());
        }
开发者ID:OscarNET,项目名称:Hexa.Core,代码行数:10,代码来源:ValidateEventListener.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: Initialize

        public static void Initialize(Configuration cfg, ValidatorEngine ve)
        {
            //Apply To DDL
            if (ve.ApplyToDDL)
            {
                foreach (PersistentClass persistentClazz in cfg.ClassMappings)
                {
                    ApplyValidatorToDDL(persistentClazz, ve);
                }
            }

            //Autoregister Listeners
            if (ve.AutoRegisterListeners)
            {
                cfg.SetListeners(ListenerType.PreInsert,
                                 cfg.EventListeners.PreInsertEventListeners.Concat(new[] {new ValidatePreInsertEventListener()}).ToArray());
                cfg.SetListeners(ListenerType.PreUpdate,
                                                 cfg.EventListeners.PreUpdateEventListeners.Concat(new[] { new ValidatePreUpdateEventListener() }).ToArray());
            }
        }
开发者ID:mpielikis,项目名称:nhibernate-contrib,代码行数:20,代码来源:ValidatorInitializer.cs

示例5: OverrideIn

 public static void OverrideIn(Configuration configuration)
 {
     configuration.SetListeners(
         ListenerType.FlushEntity,
         new IFlushEntityEventListener[] { new AuditFlushEntityEventListener() });
 }
开发者ID:OscarNET,项目名称:Hexa.Core,代码行数:6,代码来源:AuditFlushEntityEventListener.cs

示例6: NHContextFactory

        public NHContextFactory(DbProvider provider, string connectionString, string cacheProvider, Assembly mappingsAssembly, IoCContainer container)
        {
            _DbProvider = provider;
            _connectionString = connectionString;

            FluentConfiguration cfg = null;

            switch (_DbProvider)
            {
                case DbProvider.MsSqlProvider:
                {
                    cfg = Fluently.Configure().Database(MsSqlConfiguration.MsSql2008
                        .Raw("format_sql", "true")
                        .ConnectionString(_connectionString))
                        .ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.SqlExceptionConverter, typeof(SqlExceptionHandler).AssemblyQualifiedName))
                        .ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.DefaultSchema, "dbo"));

                    break;
                }
                case DbProvider.SQLiteProvider:
                {
                    cfg = Fluently.Configure().Database(SQLiteConfiguration.Standard
                        .Raw("format_sql", "true")
                        .ConnectionString(_connectionString));

                    _InMemoryDatabase = _connectionString.ToUpperInvariant().Contains(":MEMORY:");

                    break;
                }
                case DbProvider.SqlCe:
                {
                    cfg = Fluently.Configure().Database(MsSqlCeConfiguration.Standard
                            .Raw("format_sql", "true")
                            .ConnectionString(_connectionString))
                            .ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.SqlExceptionConverter, typeof(SqlExceptionHandler).AssemblyQualifiedName));
                        
                    _validationSupported = false;

                    break;
                }
                case DbProvider.Firebird:
                {
                    cfg = Fluently.Configure().Database(new FirebirdConfiguration()
                            .Raw("format_sql", "true")
                            .ConnectionString(_connectionString));

                    break;
                }
				case DbProvider.PostgreSQLProvider:
                {
                    cfg = Fluently.Configure().Database(PostgreSQLConfiguration.PostgreSQL82
                            .Raw("format_sql", "true")
                            .ConnectionString(_connectionString));
				
					_validationSupported = false;

                    break;
                }
            }

            Guard.IsNotNull(cfg, string.Format("Db provider {0} is currently not supported.", _DbProvider.GetEnumMemberValue()));

            var pinfo = typeof(FluentConfiguration)
                .GetProperty("Configuration", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

            var nhConfiguration = pinfo.GetValue(cfg, null);
            container.RegisterInstance<Configuration>(nhConfiguration);

            cfg.Mappings(m => m.FluentMappings.Conventions.AddAssembly(typeof(NHContextFactory).Assembly))
                .Mappings(m => m.FluentMappings.Conventions.AddAssembly(mappingsAssembly))
                .Mappings(m => m.FluentMappings.AddFromAssembly(mappingsAssembly))
                .Mappings(m => m.HbmMappings.AddFromAssembly(typeof(NHContextFactory).Assembly))
                .Mappings(m => m.HbmMappings.AddFromAssembly(mappingsAssembly))
				.ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.BatchSize, "100"))
                .ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.UseProxyValidator, "true"));

            if (!string.IsNullOrEmpty(cacheProvider))
            {
                cfg.ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.CacheProvider, cacheProvider)) //"NHibernate.Cache.HashtableCacheProvider"
                    .ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.UseSecondLevelCache, "true"))
                    .ExposeConfiguration(c => c.Properties.Add(NHibernate.Cfg.Environment.UseQueryCache, "true"));
            }

            _builtConfiguration = cfg.BuildConfiguration();
            _builtConfiguration.SetProperty(NHibernate.Cfg.Environment.ProxyFactoryFactoryClass, 
                typeof(NHibernate.ByteCode.Castle.ProxyFactoryFactory).AssemblyQualifiedName);

            #region Add Listeners to NHibernate pipeline....

            _builtConfiguration.SetListeners(ListenerType.FlushEntity,
                new IFlushEntityEventListener[] { new AuditFlushEntityEventListener() });

            _builtConfiguration.SetListeners(ListenerType.PreInsert,
                _builtConfiguration.EventListeners.PreInsertEventListeners.Concat<IPreInsertEventListener>(
                new IPreInsertEventListener[] { new ValidateEventListener(), new AuditEventListener() }).ToArray());

            _builtConfiguration.SetListeners(ListenerType.PreUpdate,
                _builtConfiguration.EventListeners.PreUpdateEventListeners.Concat<IPreUpdateEventListener>(
                new IPreUpdateEventListener[] { new ValidateEventListener(), new AuditEventListener() }).ToArray());

//.........这里部分代码省略.........
开发者ID:rretamal,项目名称:Hexa.Core,代码行数:101,代码来源:NHContextFactory.cs

示例7: SetListener

 public static void SetListener(Configuration config, object listener) {
     if (listener == null)
         throw new ArgumentNullException("listener");
     foreach (var intf in listener.GetType().GetInterfaces()) {
         var intf1 = intf;
         var listenerInfo = ListenerInfo.Where(i => i.Intf == intf1);
         foreach (var i in listenerInfo) {
             var currentListeners = i.ListenerCollection(config.EventListeners);
             config.SetListeners(i.ListenerType, AppendToArray(currentListeners, listener));
         }
     }
 }
开发者ID:FilipVV,项目名称:SolrNet,代码行数:12,代码来源:NHHelper.cs

示例8: OverrideIn

 public static void OverrideIn(Configuration configuration)
 {
     configuration.SetListeners(
         ListenerType.Flush,
         new IFlushEventListener[] { new FixedDefaultFlushEventListener() });
 }
开发者ID:devworker55,项目名称:Mammatus,代码行数:6,代码来源:FixedDefaultFlushEventListener.cs


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