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


C# IniFile.ContainsKey方法代码示例

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


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

示例1: TestData

        public static Task<List<string>> TestData(string carDir, double weight) {
            return Task.Run(() => {
                var errors = new List<string>();

                try {
                    var acdFile = Path.Combine(carDir, "data.acd");
                    var acd = File.Exists(acdFile) ? Acd.FromFile(acdFile) : null;
                    
                    var aeroIni = new IniFile(carDir, "aero.ini", acd);
                    if (aeroIni.ContainsKey("DATA")) {
                        errors.Add("acd-obsolete-aero-data");
                    }

                    if (weight > 0) {
                        var carIni = new IniFile(carDir, "car.ini", acd);
                        if (Math.Abs(weight + 75.0 - carIni["BASIC"].GetDouble("TOTALMASS", 0d)) > 90.0) {
                            errors.Add("acd-invalid-weight");
                        }
                    }
                } catch (Exception) {
                    errors.Add("acd-test-error");
                }

                GC.Collect();
                return errors;
            });
        }
开发者ID:gro-ove,项目名称:actools,代码行数:27,代码来源:DataFixer.cs

示例2: LoadData

        protected override void LoadData(IniFile ini) {
            Name = ini["EVENT"].GetPossiblyEmpty("NAME");
            Description = AcStringValues.DecodeDescription(ini["EVENT"].GetPossiblyEmpty("DESCRIPTION"));

            TrackId = ini["RACE"].GetNonEmpty("TRACK");
            TrackConfigurationId = ini["RACE"].GetNonEmpty("CONFIG_TRACK");
            CarId = ini["RACE"].GetNonEmpty("MODEL");
            CarSkinId = ini["CAR_0"].GetNonEmpty("SKIN");
            WeatherId = ini["WEATHER"].GetNonEmpty("NAME") ?? WeatherManager.Instance.GetDefault()?.Id;

            Time = (int)Game.ConditionProperties.GetSeconds(ini["LIGHTING"].GetInt("SUN_ANGLE", 40));
            Temperature = ini["TEMPERATURE"].GetDouble("AMBIENT", 26);
            RoadTemperature = ini["TEMPERATURE"].GetDouble("ROAD", 32);

            TrackPreset = Game.DefaultTrackPropertiesPresets.GetByIdOrDefault(ini["DYNAMIC_TRACK"].GetIntNullable("PRESET")) ??
                    Game.DefaultTrackPropertiesPresets[4];
            DisplayType = ini.ContainsKey(@"SESSION_1") ? ToolsStrings.Common_Weekend :
                    (ini["SESSION_0"].GetNonEmpty("NAME")?.Replace(@" Session", "") ?? ToolsStrings.Session_Race);

            StartingPosition = ini["SESSION_0"].GetIntNullable("STARTING_POSITION");
            OpponentsCount = ini["RACE"].GetInt("CARS", 1) - 1;

            if (OpponentsCount > 0 && StartingPosition == null) {
                StartingPosition = OpponentsCount + 1;
            }

            if (StartingPosition != null || ini.ContainsKey(@"SESSION_1")) {
                Laps = ini["SESSION_0"].GetIntNullable("LAPS") ?? ini["RACE"].GetIntNullable("RACE_LAPS") ?? 0;
            } else {
                Laps = null;
            }

            AiLevel = ini["RACE"].GetInt("AI_LEVEL", 100);

            LoadObjects();
            LoadConditions(ini);
            LoadProgress();
        }
开发者ID:gro-ove,项目名称:actools,代码行数:38,代码来源:KunosEventObjectBase.cs

示例3: Test


//.........这里部分代码省略.........
        AssertEqual(values[12].comment, "");
        AssertEqual(values[13].comment, "Comment 14");

        AssertEqual(testIni1.ToString(),
                    "Key 1 = 1\n"                                     +
                    "; Comment 2\n"                                   +
                    "Key 2 = 2\n"                                     +
                    "Key 3 = 0.1\n"                                   +
                    "; Comment 4\n"                                   +
                    "Key 4 = 0.2\n"                                   +
                    "Key 5 = 0.1\n"                                   +
                    "; Comment 6\n"                                   +
                    "Key 6 = 0.2\n"                                   +
                    "Key 7 = True\n"                                  +
                    "; Comment 8\n"                                   +
                    "Key 8 = False\n"                                 +
                    "Key 9 = 010204080F235DA7D8\n"                    +
                    "; Comment 10\n"                                  +
                    "Key 10 = 010204080F235DA7D8\n"                   +
                    "Key 11 = [KeyPair: key=1, value=2, comment=3]\n" +
                    "; Comment 12\n"                                  +
                    "Key 12 = [KeyPair: key=1, value=2, comment=3]\n" +
                    "Key 13 = \" Hello\"\n"                          +
                    "; Comment 14\n"                                  +
                    "Key 14 = \"World \"\n");

        testIni2.Parse(testIni1.ToString());
        AssertEqual(testIni1, testIni2);
        #endregion

        // ---------------------------------------------------------------------------------

        #region IniFile ContainsKey function
        AssertEqual(testIni1.ContainsKey("Key 1"),   true);
        AssertEqual(testIni1.ContainsKey("Nothing"), false);
        #endregion

        // ---------------------------------------------------------------------------------

        #region IniFile Remove function
        AssertEqual(testIni1.Remove("Key 1"),   true);
        AssertEqual(testIni1.Remove("Key 7"),   true);
        AssertEqual(testIni1.Remove("Key 14"),  true);
        AssertEqual(testIni1.Remove("Nothing"), true);

        AssertEqual(testIni1.count,        11);
        AssertEqual(testIni1.keys.Count,   11);
        AssertEqual(testIni1.values.Count, 11);
        AssertEqual(testIni1.currentGroup, "");

        keys   = testIni1.keys;
        values = testIni1.values;

        AssertEqual(keys[0],  "Key 2");
        AssertEqual(keys[1],  "Key 3");
        AssertEqual(keys[2],  "Key 4");
        AssertEqual(keys[3],  "Key 5");
        AssertEqual(keys[4],  "Key 6");
        AssertEqual(keys[5],  "Key 8");
        AssertEqual(keys[6],  "Key 9");
        AssertEqual(keys[7],  "Key 10");
        AssertEqual(keys[8],  "Key 11");
        AssertEqual(keys[9],  "Key 12");
        AssertEqual(keys[10], "Key 13");

        AssertEqual(values[0].key,  "Key 2");
开发者ID:Gris87,项目名称:IniFile,代码行数:67,代码来源:IniFile_DemoScript.cs

示例4: PrepareIniRaceMode

        public static void PrepareIniRaceMode(RaceProperties properties) {
            var ini = Path.Combine(FileUtils.GetDocumentsCfgDirectory(), "race.ini");

            var iniFile = new IniFile(ini);
            for (var i = 1; i < 100; i++) {
                var key = "CAR_" + i;
                if (iniFile.ContainsKey(key)) {
                    iniFile.Remove(key);
                } else {
                    break;
                }
            }
            iniFile.Save();

            DisableGhostCar();

            IniFile.Write(ini, "RACE", "CARS", properties.BotCars.Count() + 1);
            IniFile.Write(ini, "RACE", "AI_LEVEL", properties.AiLevel);
            IniFile.Write(ini, "RACE", "DRIFT_MODE", "0");
            IniFile.Write(ini, "RACE", "RACE_LAPS", properties.RaceLaps);
            IniFile.Write(ini, "RACE", "FIXED_SETUP", properties.FixedSetup);
            IniFile.Write(ini, "RACE", "PENALTIES", properties.Penalties);

            IniFile.Write(ini, "GROOVE", "VIRTUAL_LAPS", "10");
            IniFile.Write(ini, "GROOVE", "MAX_LAPS", "30");
            IniFile.Write(ini, "GROOVE", "STARTING_LAPS", "0");

            IniFile.Write(ini, "SESSION_0", "NAME", "Quick Race");
            IniFile.Write(ini, "SESSION_0", "TYPE", "3");
            IniFile.Write(ini, "SESSION_0", "LAPS", properties.RaceLaps);
            IniFile.Write(ini, "SESSION_0", "STARTING_POSITION", properties.StartingPosition);
            IniFile.Write(ini, "SESSION_0", "DURATION_MINUTES", "0");
            IniFile.Write(ini, "SESSION_0", "SPAWN_SET", "START");

            var j = 0;
            foreach (var botCar in properties.BotCars) {
                var section = "CAR_" + ++j;
                IniFile.Write(ini, section, "MODEL", botCar.CarId);
                IniFile.Write(ini, section, "MODEL_CONFIG", "");
                IniFile.Write(ini, section, "SETUP", botCar.Setup);
                IniFile.Write(ini, section, "AI_LEVEL", botCar.AiLevel);
                IniFile.Write(ini, section, "SKIN", botCar.SkinId);
                IniFile.Write(ini, section, "DRIVER_NAME", botCar.DriverName);
                IniFile.Write(ini, section, "NATIONALITY", botCar.Nationality);
            }
        }
开发者ID:gro-ove,项目名称:actools,代码行数:46,代码来源:Game_Obsolete.cs

示例5: LoadConfig

        public void LoadConfig()
        {
            string iniFilePath = IniConfigFileName;

            if (!File.Exists(iniFilePath))
                SaveConfig(); // Generate default config file

            IniFile iniFile = new IniFile();
            iniFile.TryLoad(iniFilePath);

            if (iniFile.ContainsKey("sourcePath"))
                sourcePath = iniFile["sourcePath"];
            if (iniFile.ContainsKey("destinationPath"))
                destinationPath = iniFile["destinationPath"];
            if (iniFile.ContainsKey("recursive"))
                Recursive = iniFile["recursive"].ToBool();
            if (iniFile.ContainsKey("locale"))
                Locale = new CultureInfo(iniFile["locale"]);
            if (iniFile.ContainsKey("patternImage"))
                DestinationPatternImage = iniFile["patternImage"];
            if (iniFile.ContainsKey("patternAudio"))
                DestinationPatternAudio = iniFile["patternAudio"];
            if (iniFile.ContainsKey("patternVideo"))
                DestinationPatternVideo = iniFile["patternVideo"];
            if (iniFile.ContainsKey("precondition"))
                CopyPrecondition = iniFile["precondition"].ToEnum<CopyPrecondition>();
            if (iniFile.ContainsKey("comparator"))
                FileComparator = iniFile["comparator"].ToEnum<FileComparator>();
            if (iniFile.ContainsKey("copyMode"))
                CopyMode = iniFile["copyMode"].ToEnum<CopyMode>();
            if (iniFile.ContainsKey("exceptionHandling"))
                ExceptionHandling = iniFile["exceptionHandling"].ToEnum<ExceptionHandling>();
            if (iniFile.ContainsKey("verifyFiles"))
                VerifyFiles = iniFile["verifyFiles"].ToBool();
        }
开发者ID:RiJo,项目名称:ExifOrganizer,代码行数:35,代码来源:MediaOrganizer.cs


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