本文整理汇总了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));
}
}
示例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());
}
示例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;
}
示例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());
}
}
示例5: OverrideIn
public static void OverrideIn(Configuration configuration)
{
configuration.SetListeners(
ListenerType.FlushEntity,
new IFlushEntityEventListener[] { new AuditFlushEntityEventListener() });
}
示例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());
//.........这里部分代码省略.........
示例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));
}
}
}
示例8: OverrideIn
public static void OverrideIn(Configuration configuration)
{
configuration.SetListeners(
ListenerType.Flush,
new IFlushEventListener[] { new FixedDefaultFlushEventListener() });
}