本文整理汇总了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();
}
示例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");
}
}
示例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: 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());
}
示例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;
}
示例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>();
});
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
示例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());
}
示例12: Configure
protected override void Configure(Configuration cfg)
{
cfg.SetListener(ListenerType.PreInsert, new PreSaveDoVeto());
}
示例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();
}
}
示例14: AddAuditor
private static void AddAuditor(Configuration config)
{
config.SetListener(ListenerType.PostUpdate, new AuditUpdateListener());
}
示例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;
}