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


C# Configuration.AddFile方法代码示例

本文整理汇总了C#中NHibernate.Cfg.Configuration.AddFile方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.AddFile方法的具体用法?C# Configuration.AddFile怎么用?C# Configuration.AddFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.Cfg.Configuration的用法示例。


在下文中一共展示了Configuration.AddFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: main

		public static void main(String[] args)
		{
			try
			{
				Configuration cfg = new Configuration();

				bool script = true;
				// If true then execute db updates, otherwise just generate and display updates
				bool doUpdate = true;
				//String propFile = null;

				for (int i = 0; i < args.Length; i++)
				{
					if (args[i].StartsWith("--"))
					{
						if (args[i].Equals("--quiet"))
						{
							script = false;
						}
						else if (args[i].StartsWith("--properties="))
						{
							throw new NotSupportedException("No properties file for .NET, use app.config instead");
							//propFile = args[i].Substring( 13 );
						}
						else if (args[i].StartsWith("--config="))
						{
							cfg.Configure(args[i].Substring(9));
						}
						else if (args[i].StartsWith("--text"))
						{
							doUpdate = false;
						}
						else if (args[i].StartsWith("--naming="))
						{
							cfg.SetNamingStrategy(
								(INamingStrategy) Activator.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9)))
								);
						}
					}
					else
					{
						cfg.AddFile(args[i]);
					}
				}

				/* NH: No props file for .NET
				 * if ( propFile != null ) {
					Hashtable props = new Hashtable();
					props.putAll( cfg.Properties );
					props.load( new FileInputStream( propFile ) );
					cfg.SetProperties( props );
				}*/

				new SchemaUpdate(cfg).Execute(script, doUpdate);
			}
			catch (Exception e)
			{
				log.Error("Error running schema update", e);
				Console.WriteLine(e);
			}
		}
开发者ID:pallmall,项目名称:WCell,代码行数:61,代码来源:SchemaUpdate.cs

示例2: OpenSession

 public static ISession OpenSession()
 {
     var configuration = new Configuration();
     var configurationPath = HttpContext.Current.Server.MapPath(@"~\Models\hibernate.cfg.xml");
     configuration.Configure(configurationPath);
     configuration.AddFile(HttpContext.Current.Server.MapPath(@"~\Models\Comment.hbm.xml"));
     configuration.AddFile(HttpContext.Current.Server.MapPath(@"~\Models\UserProfile.hbm.xml"));
     ISessionFactory sessionFactory = configuration.BuildSessionFactory();
     return sessionFactory.OpenSession();
 }
开发者ID:scepanovicmarko,项目名称:commentsys,代码行数:10,代码来源:NHibernateSession.cs

示例3: MakeSession

        public static ISession MakeSession()
        {
            var configuration = new Configuration();

            configuration.Configure(@"C:\GitRepository\PersonCRUD\PersonCRUD.Domain\Nhibernate\Configuration\hibernate.cfg.xml");
            configuration.AddFile(@"C:\GitRepository\PersonCRUD\PersonCRUD.Domain\Nhibernate\Mapping\Person.hbm.xml");
            configuration.AddFile(@"C:\GitRepository\PersonCRUD\PersonCRUD.Domain\Nhibernate\Mapping\Phone.hbm.xml");

            ISessionFactory sessionFactory = configuration.BuildSessionFactory();
            return sessionFactory.OpenSession();
        }
开发者ID:Anton-Ovch,项目名称:Valtech_,代码行数:11,代码来源:Session.cs

示例4: InitalizeSessionFactory

        public static void InitalizeSessionFactory(params FileInfo[] hbmFiles)
        {
            if (SessionFactory != null)
                return;

            var properties = new Dictionary<string, string>
                                 {
                                     {"connection.driver_class", "NHibernate.Driver.SQLite20Driver"},
                                     {"dialect", "NHibernate.Dialect.SQLiteDialect"},
                                     {"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
                                     {"connection.connection_string", "Data Source=askme.db;Version=3;New=True;"},
                                     {"connection.release_mode", "on_close"},
                                     {"show_sql", "true"},
                                     {"proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"}
                                 };

            Config = new Configuration {Properties = properties};

            foreach (FileInfo mappingFile in hbmFiles)
            {
                Config = Config.AddFile(mappingFile);
            }
            Config.BuildMapping();
            SessionFactory = Config.BuildSessionFactory();
        }
开发者ID:karthikbv,项目名称:askme,代码行数:25,代码来源:NHibernateInMemoryBase.cs

示例5: OpenSession

 public static ISession OpenSession()
 {
     var configuration = new Configuration();
     var configurationPath = HttpContext.Current.Server.MapPath(@"~\Models\Nhibernate\hibernate.cfg.xml");
     configuration.Configure(configurationPath);
     var employeeConfigurationFile = HttpContext.Current.Server.MapPath(@"~\Models\Nhibernate\Employee.hbm.xml");
     configuration.AddFile(employeeConfigurationFile);
     ISessionFactory sessionFactory = configuration.BuildSessionFactory();
     return sessionFactory.OpenSession();
 }
开发者ID:JonathanZapata,项目名称:TutorialNHibernate,代码行数:10,代码来源:NHibernateSession.cs

示例6: AddMappingsFromFilesystem

    static void AddMappingsFromFilesystem(Configuration nhConfiguration)
    {
        var folder = Directory.GetCurrentDirectory();
        var hmbFiles = Directory.GetFiles(folder, "*.hbm.xml", SearchOption.TopDirectoryOnly);

        foreach (var file in hmbFiles)
        {
            nhConfiguration.AddFile(file);
        }
    }
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:10,代码来源:Program.cs

示例7: OpenSession

        public static ISession OpenSession()
        {
            var nHConfig = new Configuration();
            var configurationPath= HttpContext.Current.Server.MapPath(@"~\Models\NHibernate\hibernate.cfg.xml");
            nHConfig.Configure(configurationPath);

            var employeeConfig = HttpContext.Current.Server.MapPath(@"~\Models\NHibernate\EmployeeBranch.hbm.xml");
            nHConfig.AddFile(employeeConfig);
            ISessionFactory sessionFactory = nHConfig.BuildSessionFactory();

            return sessionFactory.OpenSession();
        }
开发者ID:nikhil750,项目名称:DotNetGit,代码行数:12,代码来源:NHibernateSession.cs

示例8: Process

 public void Process(string name, Configuration nhConfig)
 {
     foreach (var file in GetMappingFiles())
     {
         nhConfig.AddFile(file);
         // HBM.XML file must be named to match entity-name.
         var entityName = file.Name.Replace(".hbm.xml", string.Empty);
         var nhMappingInfo = nhConfig.GetClassMapping(entityName);
         var entityDefinition = definitionCreator.CreateFrom(nhMappingInfo);
         definitionProvider.Add(entityDefinition);
     }
 }
开发者ID:sclaughl,项目名称:NhDynamicCrud,代码行数:12,代码来源:DynamicMappingFileContributor.cs

示例9: Main

		public static void Main(string[] args)
		{
			try
			{
				var cfg = new Configuration();

				//string propFile = null;

				for (int i = 0; i < args.Length; i++)
				{
					if (args[i].StartsWith("--"))
					{
						//if (args[i].StartsWith("--properties="))
						//{
						//  propFile = args[i].Substring(13);
						//}
						//else 
						if (args[i].StartsWith("--config="))
						{
							cfg.Configure(args[i].Substring(9));
						}
						else if (args[i].StartsWith("--naming="))
						{
							cfg.SetNamingStrategy(
								(INamingStrategy)
								Cfg.Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(args[i].Substring(9))));
						}
					}
					else
					{
						cfg.AddFile(args[i]);
					}
				}
				/* NH: No props file for .NET
				if ( propFile != null ) {
					Properties props = new Properties();
					props.putAll( cfg.getProperties() );
					props.load( new FileInputStream( propFile ) );
					cfg.setProperties( props );
				}
				*/
				new SchemaValidator(cfg).Validate();
			}
			catch (Exception e)
			{
				log.Error("Error running schema update", e);
				Console.WriteLine(e);
			}
		}
开发者ID:renefc3,项目名称:nhibernate,代码行数:49,代码来源:SchemaValidator.cs

示例10: OpenSession

        public static ISession OpenSession()
        {
            var configuration = new Configuration();

            var configurationPath =
                HttpContext.Current.Server.MapPath(@"~\Models\NHibernate\Configuration\hibernate.cfg.xml");

            configuration.Configure(configurationPath);

            var usersConfigurationFile =
                HttpContext.Current.Server.MapPath(@"~\Models\Nhibernate\Mappings\Users.hbm.xml");

            configuration.AddFile(usersConfigurationFile);

            ISessionFactory sessionFactory = configuration.BuildSessionFactory();

            return sessionFactory.OpenSession();
        }
开发者ID:rdugas,项目名称:WorkoutApp,代码行数:18,代码来源:NHibernateSession.cs

示例11: InitalizeSessionFactory

        public static void InitalizeSessionFactory(params FileInfo[] hbmFiles)
        {
            if (sessionFactory != null)
                return;

            var properties = new Dictionary<string, string>();
            properties.Add("connection.driver_class", "NHibernate.Driver.SQLite20Driver");
            properties.Add("dialect", "NHibernate.Dialect.SQLiteDialect");
            properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
            properties.Add("connection.connection_string", "Data Source=../../../database/getin.db;Version=3");
            properties.Add("connection.release_mode", "on_close");
            properties.Add("show_sql", "true");

            configuration = new Configuration();
            configuration.Properties = properties;

            foreach (FileInfo mappingFile in hbmFiles)
            {
                configuration = configuration.AddFile(mappingFile);
            }
            configuration.BuildMapping();
            sessionFactory = configuration.BuildSessionFactory();
        }
开发者ID:bagheera,项目名称:getin,代码行数:23,代码来源:NHibernateFixtureBase.cs


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