當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。