當前位置: 首頁>>代碼示例>>C#>>正文


C# Cfg類代碼示例

本文整理匯總了C#中Cfg的典型用法代碼示例。如果您正苦於以下問題:C# Cfg類的具體用法?C# Cfg怎麽用?C# Cfg使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Cfg類屬於命名空間,在下文中一共展示了Cfg類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadConfig

        public static bool ReadConfig()
        {
            if (!Directory.Exists(savepath))
                Directory.CreateDirectory(savepath);

            if (!File.Exists(filepath))
            {
                try
                {
                    CreateConfig();
                }
                catch
                {
                    return false;
                }
                return true;
            }

            try
            {
                using (var sr = new StreamReader(filepath))
                {
                    config = JsonConvert.DeserializeObject<Cfg>(sr.ReadToEnd());
                }
            }
            catch (Exception ex)
            {
                Log.ConsoleError(ex.Message);
                return false;
            }
            return true;
        }
開發者ID:Enerdy,項目名稱:AutoRank,代碼行數:32,代碼來源:Config.cs

示例2: Configure

		protected override void Configure(Cfg.Configuration configuration)
		{
			configuration.SetProperty(Cfg.Environment.BatchSize, "10");

			configuration.SetProperty(	Cfg.Environment.SqlExceptionConverter,
										typeof (MSSQLExceptionConverterExample).AssemblyQualifiedName);
		}
開發者ID:marchlud,項目名稱:nhibernate-core,代碼行數:7,代碼來源:Fixture.cs

示例3: SetupSqlServerOdbc

		private static void SetupSqlServerOdbc(Cfg.Configuration cfg)
		{
			var connStr = cfg.Properties[Cfg.Environment.ConnectionString];

			using (var conn = new OdbcConnection(connStr.Replace("Database=nhibernateOdbc", "Database=master")))
			{
				conn.Open();

				using (var cmd = conn.CreateCommand())
				{
					cmd.CommandText = "drop database nhibernateOdbc";

					try
					{
						cmd.ExecuteNonQuery();
					}
					catch(Exception e)
					{
						Console.WriteLine(e);
					}

					cmd.CommandText = "create database nhibernateOdbc";
					cmd.ExecuteNonQuery();
				}
			}
		}
開發者ID:marchlud,項目名稱:nhibernate-core,代碼行數:26,代碼來源:TestDatabaseSetup.cs

示例4: Configure

		protected override void Configure(Cfg.Configuration configuration)
		{
			if(Dialect is MsSql2000Dialect)
			{
				configuration.SetProperty(
					Cfg.Environment.SqlExceptionConverter,
					typeof(MSSQLExceptionConverterExample).AssemblyQualifiedName);
			}

			if (Dialect is Oracle8iDialect)
			{
				configuration.SetProperty(
					Cfg.Environment.SqlExceptionConverter,
					typeof(OracleClientExceptionConverterExample).AssemblyQualifiedName);
			}

			if (Dialect is PostgreSQLDialect)
			{
				configuration.SetProperty(
					Cfg.Environment.SqlExceptionConverter,
					typeof(PostgresExceptionConverterExample).AssemblyQualifiedName);
			}

			if (Dialect is FirebirdDialect)
			{
				configuration.SetProperty(
					Cfg.Environment.SqlExceptionConverter,
					typeof(FbExceptionConverterExample).AssemblyQualifiedName);
			}
		}
開發者ID:nhibernate,項目名稱:nhibernate-core,代碼行數:30,代碼來源:SQLExceptionConversionTest.cs

示例5: Configure

		//protected override bool AppliesTo(Dialect.Dialect dialect)
		//{
		//  // this test work only with Field interception (NH-1618)
		//  return FieldInterceptionHelper.IsInstrumented( new Person() );
		//}
		protected override void Configure(Cfg.Configuration configuration)
		{
			configuration.SetProperty(Environment.ProxyFactoryFactoryClass,
										typeof(NHibernate.ByteCode.Castle.ProxyFactoryFactory).AssemblyQualifiedName);
			configuration.SetProperty(Environment.MaxFetchDepth, "2");
			configuration.SetProperty(Environment.UseSecondLevelCache, "false");
		}
開發者ID:juanplopes,項目名稱:nhibernate,代碼行數:12,代碼來源:LazyOneToOneTest.cs

示例6: Configure

		protected override void Configure(Cfg.Configuration configuration)
		{
			configuration.Cache(x =>
								{
									x.Provider<HashtableCacheProvider>();
									x.UseQueryCache = true;
								});
		}
開發者ID:Leftyx,項目名稱:nhibernate-core,代碼行數:8,代碼來源:CachingWithTrasformerTests.cs

示例7: AddMappings

		protected override void AddMappings(Cfg.Configuration configuration)
		{
			// Set some properties that must be set before the mappings are added.
			// (The overridable Configure(cfg) is called AFTER AddMappings(cfg).)
			configuration.SetProperty(Cfg.Environment.PreferPooledValuesLo, _preferLo.ToString().ToLower());

			base.AddMappings(configuration);
		}
開發者ID:marchlud,項目名稱:nhibernate-core,代碼行數:8,代碼來源:DefaultOptimizedSequenceTest.cs

示例8: Configure

		protected override void Configure(Cfg.Configuration configuration)
		{
			configuration.AddProperties(new Dictionary<string, string>
			                            	{
			                            		{
			                            			Cfg.Environment.QueryTranslator,
			                            			typeof (NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).FullName
			                            			}
			                            	}
				);
		}
開發者ID:kstenson,項目名稱:NHibernate.Search,代碼行數:11,代碼來源:Fixture.cs

示例9: Configure

		protected override void Configure(Cfg.Configuration configuration)
		{
			var assembly = GetType().Assembly;
			string mappingNamespace = GetType().Namespace;
			foreach (var resource in assembly.GetManifestResourceNames())
			{
				if (resource.StartsWith(mappingNamespace) && resource.EndsWith(".hbm.xml"))
				{
					configuration.AddResource(resource, assembly);
				}
			}
		}
開發者ID:nkmajeti,項目名稱:nhibernate,代碼行數:12,代碼來源:BaseFixture.cs

示例10: getFor

        public static AuditConfiguration getFor(Cfg.Configuration cfg) {
            AuditConfiguration verCfg = null;
            if(cfgs.Keys.Contains(cfg))
                verCfg = cfgs[cfg];
            else{
                verCfg = new AuditConfiguration(cfg);
                cfgs.Add(cfg, verCfg);
                
                cfg.BuildMappings();
            }

            return verCfg;
        }
開發者ID:hazzik,項目名稱:nh-contrib-everything,代碼行數:13,代碼來源:AuditConfiguration.cs

示例11: Config

        public void Config(IPersistenceUnitCfg puCfg, Cfg.Configuration configuration)
        {
           if(puCfg.Name ==  MockPersistenceUnitCfg.MockPUName )
           {
                
               configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
               configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
               configuration.SetProperty("connection.connection_string", "Server=(local);initial catalog=NHibernateBurrow;Integrated Security=SSPI");
               configuration.SetProperty("dialect", "NHibernate.Dialect.MsSql2005Dialect");

            configuration.SetProperty("adonet.batch_size", testAdoBatchSize.ToString());
         
           }
        }
開發者ID:hazzik,項目名稱:NHibernate.Burrow,代碼行數:14,代碼來源:ConfiguratorFixture.cs

示例12: SetupFirebird

		private static void SetupFirebird(Cfg.Configuration cfg)
		{
			try
			{
				if (File.Exists("NHibernate.fdb"))
					File.Delete("NHibernate.fdb");
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
			}

			FbConnection.CreateDatabase("Database=NHibernate.fdb;ServerType=1");
		}
開發者ID:pontillo,項目名稱:PowerNap,代碼行數:14,代碼來源:TestDatabaseSetup.cs

示例13: Load

 private static void Load()
 {
     if (File.Exists(configName))
     {
         StreamReader sr = new StreamReader(configName);
         cfg = (Cfg)jsonSerializer.Deserialize(sr, typeof(Cfg));
         sr.Close();
     }
     else
     {
         cfg = new Cfg();
         Save();
     }
 }
開發者ID:xopuct,項目名稱:notes,代碼行數:14,代碼來源:ClientConfig.cs

示例14: Configure

		protected override void Configure(Cfg.Configuration configuration)
		{
			foreach (var cls in configuration.ClassMappings)
			{
				foreach (var prop in cls.PropertyIterator)
				{
					foreach (var col in prop.ColumnIterator)
					{
						if (col is Column)
						{
							var column = col as Column;
							if (column.SqlType == "nvarchar(max)")
								column.SqlType = Dialect.GetLongestTypeName(DbType.String);
						}
					}
				}
			}
		}
開發者ID:Ruhollah,項目名稱:nhibernate-core,代碼行數:18,代碼來源:Fixture.cs

示例15: SetupNpgsql

		private static void SetupNpgsql(Cfg.Configuration cfg)
		{
			var connStr = cfg.Properties[Cfg.Environment.ConnectionString];

			using (var conn = new NpgsqlConnection(connStr.Replace("Database=nhibernate", "Database=postgres")))
			{
				conn.Open();

				using (var cmd = conn.CreateCommand())
				{
					cmd.CommandText = "drop database nhibernate";

					try
					{
						cmd.ExecuteNonQuery();
					}
					catch (Exception e)
					{
						Console.WriteLine(e);
					}

					cmd.CommandText = "create database nhibernate";
					cmd.ExecuteNonQuery();
				}
			}

            // Install the GUID generator function that uses the most common "random" algorithm.
            using (var conn = new NpgsqlConnection(connStr))
            {
                conn.Open();

				using (var cmd = conn.CreateCommand())
				{
                    cmd.CommandText =
                        @"CREATE OR REPLACE FUNCTION uuid_generate_v4()
                        RETURNS uuid
                        AS '$libdir/uuid-ossp', 'uuid_generate_v4'
                        VOLATILE STRICT LANGUAGE C;";

					cmd.ExecuteNonQuery();
				}
            }
		}
開發者ID:pontillo,項目名稱:PowerNap,代碼行數:43,代碼來源:TestDatabaseSetup.cs


注:本文中的Cfg類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。