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


C# Configuration.AddXmlFile方法代码示例

本文整理汇总了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();
        }
开发者ID:adymitruk,项目名称:NHibernate-Deep-Dive,代码行数:30,代码来源:SpecificationBase.cs

示例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 );
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:31,代码来源:ConfigurationFixture.cs

示例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
        {

        }
    }
开发者ID:jbvios,项目名称:mtbscout,代码行数:19,代码来源:DBHelper.cs

示例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());
     }
 }
开发者ID:Maasik,项目名称:mtbscout,代码行数:17,代码来源:DBHelper.cs

示例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();
        }
开发者ID:siwiwit,项目名称:andromda,代码行数:8,代码来源:FooBarNHibernateTests.cs


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