本文整理汇总了C#中NHibernate.Cfg.Configuration.AddXmlFile方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddXmlFile方法的具体用法?C# Configuration.AddXmlFile怎么用?C# Configuration.AddXmlFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.AddXmlFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareSessionFactory
public void PrepareSessionFactory()
{
Configuration = new Configuration();
Configuration.Proxy(p => p.ProxyFactoryFactory<ProxyFactoryFactory>())
.DataBaseIntegration(db =>
{
db.ConnectionStringName = "db";
db.Dialect<MsSql2008Dialect>();
});
Configuration.SetProperty("show_sql", "true");
Configuration.SetDefaultAssembly("NHibernateDeepDive");
Configuration.SetDefaultNamespace("NHibernate_Deep_Dive.Entities");
Configuration.AddXmlFile("ClearDatabaseScript.hbm.xml");
foreach (var mappingFile in Directory.GetFiles(MappingsDirectory))
{
Configuration.AddXmlFile(mappingFile);
}
AdjustConfiguration(Configuration);
Configuration.SessionFactory().GenerateStatistics();
SessionFactory = Configuration.BuildSessionFactory();
//new SchemaExport(Configuration).Drop(false, true);
new SchemaExport(Configuration).Execute(false, true, false);
BeforeTestRun();
PopulateDatabase();
HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();
}
示例2: InvalidXmlInHbmFile
public void InvalidXmlInHbmFile()
{
string filename = "invalid.hbm.xml";
// it's missing the class name - won't validate
string hbm = @"<?xml version='1.0' encoding='utf-8' ?>
<hibernate-mapping xmlns='urn:nhibernate-mapping-2.0'>
<class table='a'></class>
</hibernate-mapping>";
XmlDocument hbmDoc = new XmlDocument();
hbmDoc.LoadXml( hbm );
hbmDoc.Save( filename );
Configuration cfg = new Configuration();
try
{
cfg.Configure();
cfg.AddXmlFile( "invalid.hbm.xml" );
}
catch( HibernateException )
{
// just absorb it - not what we are testing
}
finally
{
// clean up the bad file - if the AddXmlFile method cleans up after
// itself we should be able to do this without problem. If it does
// property release the resource then this won't be able to access
// the file to delete.
System.IO.File.Delete( filename );
}
}
示例3: NHSessionManager
static NHSessionManager()
{
try
{
Configuration cfg = new Configuration();
string configFile = Helper.IsDevelopment()
? @"hibernate.debug.cfg.xml"
: @"hibernate.cfg.xml";
string mappingPath = PathFunctions.GetMappingPath();
cfg.Configure(Path.Combine(mappingPath, configFile));
foreach (string file in Directory.GetFiles(mappingPath, "*.hbm.xml"))
cfg.AddXmlFile(file);
factory = cfg.BuildSessionFactory();
}
catch
{
}
}
示例4: NHSessionManager
static NHSessionManager()
{
try
{
Configuration cfg = new Configuration();
string configFile = @"hibernate.cfg.xml";
string mappingPath = PathFunctions.GetMappingPath();
cfg.Configure(Path.Combine(mappingPath, configFile));
foreach (string file in Directory.GetFiles(mappingPath, "*.hbm.xml"))
cfg.AddXmlFile(file);
factory = cfg.BuildSessionFactory();
}
catch(Exception ex)
{
Log.Add(ex.ToString());
}
}
示例5: TestSetup
public void TestSetup()
{
Configuration cfg = new Configuration();
cfg.AddXmlFile(@"C:\Documents and Settings\James Avery\My Documents\My Projects\NHibernate.Nullables2\nhibtest\FooBar.hbm.xml");
factory = cfg.BuildSessionFactory();
}