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


C# ConfigFile类代码示例

本文整理汇总了C#中ConfigFile的典型用法代码示例。如果您正苦于以下问题:C# ConfigFile类的具体用法?C# ConfigFile怎么用?C# ConfigFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: PowerNodeBuilding

    public PowerNodeBuilding(string configName)
        : base(configName)
    {
        ConfigFile config = new ConfigFile(configName);

        m_MaxConnections = config.GetKey_Int("Power", "MaxConnections");
    }
开发者ID:nint22,项目名称:NovaLegacy,代码行数:7,代码来源:PowerNodeBuilding.cs

示例2: SqliteDbProvider

        public SqliteDbProvider(ConfigFile configFile)
        {
            _connectionString = string.Format("Data Source={0};Version=3", configFile.Get(DbConstants.KEY_FILE_NAME));

            _clientExec = configFile.Get(DbConstants.KEY_CLIENT_EXEC);
            _dbFileName = configFile.Get(DbConstants.KEY_FILE_NAME);
        }
开发者ID:jowasp,项目名称:WebGoat.NET,代码行数:7,代码来源:SqliteDbProvider.cs

示例3: AddXml

        /// <summary>
        /// Specify an XML file in S3 to merge with Hadoop's default configuration.
        /// </summary>
        /// <param name="file">The config file to merge with.</param>
        /// <param name="xmlPath">The path in S3 of the XML file.</param>
        public void AddXml(ConfigFile file, string xmlPath)
        {
            string arg = "";

            switch (file)
            {
                case ConfigFile.Site: 
                    arg = "-S"; 
                    break;
                case ConfigFile.Default: 
                    arg = "-D"; 
                    break;
                case ConfigFile.Core: 
                    arg = "-C"; 
                    break;
                case ConfigFile.Hdfs: 
                    arg = "-H"; 
                    break;
                case ConfigFile.Mapred: 
                    arg = "-M";
                    break;
            }

            args.Add(arg);
            args.Add(xmlPath);
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:31,代码来源:ConfigureHadoop.cs

示例4: AddKeyValue

        /// <summary>
        ///  Specify a key-value pair to merge with Hadoop's default configuration.
        /// </summary>
        /// <param name="file">The config file to merge with.</param>
        /// <param name="key">The config key.</param>
        /// <param name="value">The config value.</param>
        public void AddKeyValue(ConfigFile file, String key, String value)
        {
            String arg = "";

            switch (file)
            {
                case ConfigFile.Site: 
                    arg = "-s"; 
                    break;
                case ConfigFile.Default: 
                    arg = "-d"; break;
                case ConfigFile.Core: 
                    arg = "-c"; 
                    break;
                case ConfigFile.Hdfs: 
                    arg = "-h"; 
                    break;
                case ConfigFile.Mapred: 
                    arg = "-m"; 
                    break;
            }
        
            args.Add(arg);
            args.Add(key + "=" + value);
        }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:31,代码来源:ConfigureHadoop.cs

示例5: MySqlDbProvider

        public MySqlDbProvider(ConfigFile configFile)
        {
            if (configFile == null)
            {
                _connectionString = string.Empty;
                return;
            }

            if (!string.IsNullOrEmpty(configFile.Get(DbConstants.KEY_PWD)))
            {
                _connectionString = string.Format("SERVER={0};PORT={1};DATABASE={2};UID={3};PWD={4}",
                                                  configFile.Get(DbConstants.KEY_HOST),
                                                  configFile.Get(DbConstants.KEY_PORT),
                                                  configFile.Get(DbConstants.KEY_DATABASE),
                                                  configFile.Get(DbConstants.KEY_UID),
                                                  configFile.Get(DbConstants.KEY_PWD));
            }
            else
            {
                 _connectionString = string.Format("SERVER={0};PORT={1};DATABASE={2};UID={3}",
                                                  configFile.Get(DbConstants.KEY_HOST),
                                                  configFile.Get(DbConstants.KEY_PORT),
                                                  configFile.Get(DbConstants.KEY_DATABASE),
                                                  configFile.Get(DbConstants.KEY_UID));
            }

            _uid = configFile.Get(DbConstants.KEY_UID);
            _pwd = configFile.Get(DbConstants.KEY_PWD);
            _database = configFile.Get(DbConstants.KEY_DATABASE);
            _host = configFile.Get(DbConstants.KEY_HOST);
            _clientExec = configFile.Get(DbConstants.KEY_CLIENT_EXEC);
            _port = configFile.Get(DbConstants.KEY_PORT);
        }
开发者ID:prevoty,项目名称:WebGoat.NET,代码行数:33,代码来源:MySqlDbProvider.cs

示例6: ReadWheelsFromFiles

        /// <summary>
        /// Go through our media/wheels/ directory and find all of the wheel definitions we have, then make dictionaries out of them
        /// and add them to our one big dictionary.		
        /// </summary>
        public void ReadWheelsFromFiles()
        {
            // since we can run this whenever (like when we're tweaking files), we want to clear our dictionary first
            wheels.Clear();

            // get all of the filenames of the files in media/wheels/
            IEnumerable<string> files = Directory.EnumerateFiles("media/vehicles/", "*.wheel", SearchOption.AllDirectories);

            foreach (string filename in files) {
                // I forgot ogre had this functionality already built in
                ConfigFile cfile = new ConfigFile();
                cfile.Load(filename, "=", true);

                // each .wheel file can have multiple [sections]. We'll use each section name as the wheel name
                ConfigFile.SectionIterator sectionIterator = cfile.GetSectionIterator();
                while (sectionIterator.MoveNext()) {
                    string wheelname = sectionIterator.CurrentKey;
                    // make a dictionary
                    var wheeldict = new Dictionary<string, float>();
                    // go over every property in the file and add it to the dictionary, parsing it as a float
                    foreach (KeyValuePair<string, string> pair in sectionIterator.Current) {
                        wheeldict.Add(pair.Key, float.Parse(pair.Value, culture));
                    }

                    wheels[wheelname] = wheeldict;
                }

                cfile.Dispose();
                sectionIterator.Dispose();
            }
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:35,代码来源:WheelFactory.cs

示例7: ReadConfigFile

        public static ConfigFile ReadConfigFile(string path)
        {
            ConfigFile file = new ConfigFile();
            XmlDocument doc = new XmlDocument();
            doc.Load(path);

            if (doc.DocumentElement != null)
            {
                try
                {
                    XmlNode node = doc.DocumentElement.SelectSingleNode("appSettings");

                    file.Email = node.ChildNodes[0].Attributes[VALUE].Value;
                    file.User = node.ChildNodes[1].Attributes[VALUE].Value;
                    file.Password = node.ChildNodes[2].Attributes[VALUE].Value;
                    file.Sender = node.ChildNodes[3].Attributes[VALUE].Value;
                    file.SmtpServer = node.ChildNodes[4].Attributes[VALUE].Value;
                    file.SmtpPort = node.ChildNodes[5].Attributes[VALUE].Value;
                    file.Delay = node.ChildNodes[6].Attributes[VALUE].Value;
                    file.ConnString = node.ChildNodes[7].Attributes[VALUE].Value;
                }
                catch (Exception)
                { }
            }

            return file;
        }
开发者ID:AramisIT,项目名称:DllExchange,代码行数:27,代码来源:MainWindow.xaml.cs

示例8: ReadFromConfig

 public void ReadFromConfig(ConfigFile config)
 {
     this.name = config.Get("Emulation.DeviceName", this.name.ToString());
     string str1 = config.Get("Emulation.OSCategory", this.os.ToString());
     string str2 = config.Get("Emulation.InputCategory", this.input.ToString());
     string str3 = config.Get("Emulation.ScreenCategory", this.screen.ToString());
     string str4 = config.Get("Emulation.ScreenDensityCategory", this.screenDensity.ToString());
     Log.ConfigFile.Print("Reading Emulated Device: " + this.name + " from " + config.GetPath());
     try
     {
       this.os = (OSCategory) Enum.Parse(typeof (OSCategory), str1);
       this.input = (InputCategory) Enum.Parse(typeof (InputCategory), str2);
       this.screen = (ScreenCategory) Enum.Parse(typeof (ScreenCategory), str3);
       this.screenDensity = (ScreenDensityCategory) Enum.Parse(typeof (ScreenDensityCategory), str4);
     }
     catch (ArgumentException ex)
     {
       string format = "Could not parse {0} in {1} as a valid device!";
       object[] objArray = new object[2];
       int index1 = 0;
       string str5 = this.name;
       objArray[index1] = (object) str5;
       int index2 = 1;
       string path = config.GetPath();
       objArray[index2] = (object) path;
     //      Blizzard.Log.Warning(format, objArray);
     }
 }
开发者ID:slb1988,项目名称:StrangeIoCLearning,代码行数:28,代码来源:DevicePreset.cs

示例9: WithKeyValue

        /// <summary>
        ///  Specify a key-value pair to merge with Hadoop's default configuration.
        /// </summary>
        /// <param name="file">The config file to merge with.</param>
        /// <param name="key">The config key.</param>
        /// <param name="value">The config value.</param>
        /// <returns>A reference to this updated object so that method calls can be chained together.</returns>
        public ConfigureHadoop WithKeyValue(ConfigFile file, String key, String value)
        {
            String arg = "";

            switch (file)
            {
                case ConfigFile.Site:
                    arg = "-s";
                    break;
                case ConfigFile.Default:
                    arg = "-d"; break;
                case ConfigFile.Core:
                    arg = "-c";
                    break;
                case ConfigFile.Hdfs:
                    arg = "-h";
                    break;
                case ConfigFile.Mapred:
                    arg = "-m";
                    break;
            }

            args.Add(arg);
            args.Add(key + "=" + value);
            return this;
        }
开发者ID:davidsidlinger,项目名称:aws-sdk-net,代码行数:33,代码来源:ConfigureHadoop.cs

示例10: AddParameterDialog

        /// <summary>Create <see cref="AddParameterDialog"/>.</summary>
        /// <param name="environment">Application environment.</param>
        /// <param name="configFile">Config file to use.</param>
        public AddParameterDialog(IWorkingEnvironment environment, ConfigFile configFile)
            : this(environment)
        {
            Verify.Argument.IsFalse(configFile != ConfigFile.System && configFile != ConfigFile.User, "configFile");

            _configFile = configFile;
        }
开发者ID:Kuzq,项目名称:gitter,代码行数:10,代码来源:AddParameterDialog.cs

示例11: Read

		public static ConfigFile Read(string path)
		{
			if (String.IsNullOrWhiteSpace(path))
			{
				TShock.Log.ConsoleError("CTRS-Config: Invalid filepath given. Starting default configuration...");
				return new ConfigFile();
			}

			Directory.CreateDirectory(Path.GetDirectoryName(path));
			try
			{
				ConfigFile file = new ConfigFile();
				if (File.Exists(path))
				{
					file = JsonConvert.DeserializeObject<ConfigFile>(File.ReadAllText(path));
				}
				File.WriteAllText(path, JsonConvert.SerializeObject(file, Formatting.Indented));
				return file;
			}
			catch (Exception e)
			{
				TShock.Log.ConsoleError("CTRS-Config: " + e.Message);
				TShock.Log.Error(e.ToString());
				return new ConfigFile();
			}
		}
开发者ID:Enerdy,项目名称:CTRSystem,代码行数:26,代码来源:ConfigFile.cs

示例12: ConfigParameter

        /// <summary>Create <see cref="ConfigParameter"/>.</summary>
        /// <param name="repository">Related <see cref="Repository"/>.</param>
        /// <param name="name">Paramater name.</param>
        /// <param name="value">Parameter value.</param>
        internal ConfigParameter(IConfigAccessor configAccessor, ConfigFile configFile, string name, string value)
            : base(name)
        {
            Verify.Argument.IsNotNull(configAccessor, "configAccessor");

            _configAccessor = configAccessor;
            _configFile = configFile;
            _value = value;
        }
开发者ID:Kuzq,项目名称:gitter,代码行数:13,代码来源:ConfigParameter.cs

示例13: SetGlobalDiffToolToConfig

 public static void SetGlobalDiffToolToConfig(ConfigFile configFile, string diffTool)
 {
     if (GitCommandHelpers.VersionInUse.GuiDiffToolExist)
     {
         configFile.SetValue("diff.guitool", diffTool);
         return;
     }
     configFile.SetValue("diff.tool", diffTool);
 }
开发者ID:JakeGinnivan,项目名称:gitextensions,代码行数:9,代码来源:CheckSettingsLogic.cs

示例14: CommandCenterBuilding

    public CommandCenterBuilding(string configName)
        : base(configName)
    {
        ConfigFile config = new ConfigFile(configName);

        m_MaxPower = config.GetKey_Float("Power", "MaxEnergy");

        m_IsPowered = true;
    }
开发者ID:nint22,项目名称:NovaLegacy,代码行数:9,代码来源:CommandCenterBuilding.cs

示例15: ShipyardBuilding

    public ShipyardBuilding(string configName)
        : base(configName)
    {
        ConfigFile configFile = new ConfigFile(configName);

        m_ShipCapacity  = configFile.GetKey_Int("Shipyard", "ShipCapacity");
        m_BuildCoolDown = configFile.GetKey_Float("Shipyard", "BuildCoolDown");
        m_ShipConfig = configFile.GetKey_String("Shipyard", "ShipConfig");
    }
开发者ID:nint22,项目名称:NovaLegacy,代码行数:9,代码来源:ShipyardBuilding.cs


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