public IniFileHelper()

in aliyun-net-credentials/Utils/IniFileHelper.cs [13:47]


        public IniFileHelper(string file)
        {
            var txt = File.ReadAllText(file);
            var currentSection =
                new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);

            ini[""] = currentSection;

            foreach (var line in txt.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)
                    .Where(t => !string.IsNullOrWhiteSpace(t))
                    .Select(t => t.Trim()))
            {
                if (line.StartsWith(";"))
                {
                    continue;
                }

                if (line.StartsWith("[") && line.EndsWith("]"))
                {
                    currentSection = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
                    ini[line.Substring(1, line.LastIndexOf("]", StringComparison.Ordinal) - 1).Trim()] = currentSection;
                    continue;
                }

                var idx = line.IndexOf("=", StringComparison.Ordinal);
                if (idx == -1)
                {
                    currentSection[line.Trim()] = "";
                }
                else
                {
                    currentSection[line.Substring(0, idx).Trim()] = line.Substring(idx + 1).Trim();
                }
            }
        }