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


C# IniFile.GetInt方法代码示例

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


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

示例1: LoadFromIni

        public void LoadFromIni(IniFile iniFile, IniFile.Section ini, GameExtensionPool pool)
        {
            this.Source = (SourceType) ini.GetInt("Type");
              this.MasterServer = ini.GetString("MasterServer") ?? "hl2master.steampowered.com:27011";
              this.InitialGameID = ini.GetInt("InitialGameID");
              this.FilterMod = ini.GetString("FilterMod");
              this.FilterMap = ini.GetString("FilterMap");
              this.TagsInclude = ini.GetString("TagsInclude");
              this.TagsExclude = ini.GetString("TagsExclude");
              this.GetEmptyServers = ini.GetBool("GetEmptyServers", true);
              this.GetFullServers = ini.GetBool("GetFullServers", true);
              this.MasterServerQueryLimit = ini.GetInt("MasterServerQueryLimit", 500);
              this.GridFilter = ini.GetString("GridFilter");

              var layout = ini.GetString("GridLayout");
              if (!string.IsNullOrEmpty(layout))
            this.ServerGridLayout = new MemoryStream(Convert.FromBase64String(layout));

              this.gameExtension = pool.Get((Game) this.InitialGameID);

              if (this.Source == SourceType.CustomList)
              {
            this.servers = new List<ServerRow>();

            // new config format
            var sec = iniFile.GetSection(ini.Name + "_Servers");
            if (sec != null)
            {
              foreach (var key in sec.Keys)
              {
            var row = new ServerRow(Ip4Utils.ParseEndpoint(key), this.gameExtension);
            row.CachedName = sec.GetString(key);
            this.servers.Add(row);
              }
            }
            else
            {
              // old config format
              var oldSetting = ini.GetString("Servers") ?? "";
              foreach (var server in oldSetting.Split('\n', ' '))
              {
            var s = server.Trim();
            if (s == "") continue;
            this.servers.Add(new ServerRow(Ip4Utils.ParseEndpoint(s), this.gameExtension));
              }
            }
              }
        }
开发者ID:vtchill,项目名称:SteamServerBrowser,代码行数:48,代码来源:TabViewModel.cs

示例2: Test


//.........这里部分代码省略.........
        testIni1.EndGroup();

        AssertEqual(testIni1.ToString(),
                    "Key 1 = 1\n"                                    +
                    "\n"                                             +
                    "[Group 1]\n"                                    +
                    "\n"                                             +
                    "Key 2 = 0.2\n"                                  +
                    "\n"                                             +
                    "[Group 1/Subgroup 1]\n"                         +
                    "\n"                                             +
                    "Key 3 = 0.3\n"                                  +
                    "Key 4 = True\n"                                 +
                    "\n"                                             +
                    "[Group 2]\n"                                    +
                    "\n"                                             +
                    "Key 5 = 010204080F235DA7D8\n"                   +
                    "\n"                                             +
                    "[Group 2/Subgroup 1]\n"                         +
                    "\n"                                             +
                    "Key 6 = [KeyPair: key=1, value=2, comment=3]\n" +
                    "\n"                                             +
                    "[Group 2/Subgroup 2]\n"                         +
                    "\n"                                             +
                    "Key 7 = \"Hello World!\t\"\n");

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

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

        #region IniFile Get function
        AssertEqual(testIni1.GetInt("Key 1"),      1);
        AssertEqual(testIni1.GetInt("Nothing", 2), 2);

        testIni1.BeginGroup("Group 1");
        AssertEqual(testIni1.GetFloat("Key 2"),          0.2f);
        AssertEqual(testIni1.GetFloat("Nothing", 10.2f), 10.2f);

        testIni1.BeginGroup("Subgroup 1");
        AssertEqual(testIni1.GetDouble("Key 3"),         0.3);
        AssertEqual(testIni1.GetDouble("Nothing", 10.3), 10.3);
        testIni1.EndGroup();

        AssertEqual(testIni1.GetBool("Subgroup 1/Key 4"),          true);
        AssertEqual(testIni1.GetBool("Subgroup 1/Nothing", false), false);

        testIni1.EndGroup();

        AssertEqual(Enumerable.SequenceEqual(testIni1.GetByteArray("Group 2/Key 5"),                testBytes), true);
        AssertEqual(Enumerable.SequenceEqual(testIni1.GetByteArray("Group 2/Nothing", new byte[2]), testBytes), false);

        AssertEqual(testIni1.Get("Group 2/Subgroup 1/Key 6"),   "[KeyPair: key=1, value=2, comment=3]");
        AssertEqual(testIni1.Get("Group 2/Subgroup 1/Nothing"), "");

        AssertEqual(testIni1.GetString("Group 2/Subgroup 2/Key 7"),            "Hello World!\t");
        AssertEqual(testIni1.GetString("Group 2/Subgroup 2/Nothing", "Yahoo"), "Yahoo");

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

        keys   = testIni1.keys;
        values = testIni1.values;
开发者ID:Gris87,项目名称:IniFile,代码行数:67,代码来源:IniFile_DemoScript.cs

示例3: ApplyAppSettingsFromIni

        private int ApplyAppSettingsFromIni(IniFile ini, IniFile.Section options, out string[] masterServers)
        {
            masterServers = (options.GetString("ApplyAppSettingsFromXml") ?? "").Split(',');
              this.miShowOptions.Down = options.GetBool("ShowOptions");
              this.miShowServerQuery.Down = options.GetBool("ShowServerQuery");

              this.rbAddressHidden.Checked = options.GetInt("ShowAddressMode") == 0;
              this.rbAddressQueryPort.Checked = options.GetInt("ShowAddressMode") == 1;
              this.rbAddressGamePort.Checked = options.GetInt("ShowAddressMode") == 2;
              this.cbRefreshSelectedServer.Checked = options.GetBool("RefreshSelected", true);
              this.spinRefreshInterval.EditValue = options.GetDecimal("RefreshInterval");
              this.rbUpdateListAndStatus.Checked = options.GetBool("AutoUpdateList", true);
              this.rbUpdateStatusOnly.Checked = options.GetBool("AutoUpdateInfo");
              this.cbFavServersOnTop.Checked = options.GetBool("KeepFavServersOnTop", true);
              this.cbHideUnresponsiveServers.Checked = options.GetBool("HideUnresponsiveServers", true);
              this.cbRememberColumnLayout.Checked = options.GetBool("ColumnLayoutPerTab");

              // load favorite servers
              var favs = ini.GetSection("FavoriteServers");
              if (favs != null)
              {
            foreach (var server in favs.Keys)
            {
              if (server == "") continue;
              var parts = server.Split(':');
              this.favServers.Add(new IPEndPoint(IPAddress.Parse(parts[0]), int.Parse(parts[1])), favs.GetString(server));
            }
              }
              return options.GetInt("TabIndex");
        }
开发者ID:vtchill,项目名称:SteamServerBrowser,代码行数:30,代码来源:ServerBrowserForm.cs


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