當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。