internal IniParser(string iniPath) { IniParser.SectionPair sectionPair = new IniParser.SectionPair(); string str = null; this.iniFilePath = iniPath; this.Name = Path.GetFileNameWithoutExtension(iniPath); if (!File.Exists(iniPath)) { throw new FileNotFoundException(string.Concat("Unable to locate ", iniPath)); } try { using (TextReader streamReader = new StreamReader(iniPath)) { for (string i = streamReader.ReadLine(); i != null; i = streamReader.ReadLine()) { i = i.Trim(); if (i != "") { if (!i.StartsWith("[") || !i.EndsWith("]")) { if (i.StartsWith(";")) { i = string.Concat(i.Replace("=", "%eq%"), "=%comment%"); } string[] strArrays = i.Split(new char[] { '=' }, 2); string str1 = null; if (str == null) { str = "ROOT"; } sectionPair.Section = str; sectionPair.Key = strArrays[0]; if ((int)strArrays.Length > 1) { str1 = strArrays[1]; } try { this.keyPairs.Add(sectionPair, str1); this.tmpList.Add(sectionPair); } catch { } } else { str = i.Substring(1, i.Length - 2); } } } streamReader.Close(); } } catch { } }
internal string GetSetting(string sectionName, string settingName) { IniParser.SectionPair sectionPair = new IniParser.SectionPair(); sectionPair.Section = sectionName; sectionPair.Key = settingName; return((string)this.keyPairs[sectionPair]); }
internal bool ContainsSetting(string sectionName, string settingName) { IniParser.SectionPair sectionPair = new IniParser.SectionPair(); sectionPair.Section = sectionName; sectionPair.Key = settingName; return(this.keyPairs.Contains(sectionPair)); }
internal void DeleteSetting(string sectionName, string settingName) { IniParser.SectionPair sectionPair = new IniParser.SectionPair(); sectionPair.Section = sectionName; sectionPair.Key = settingName; if (this.keyPairs.ContainsKey(sectionPair)) { this.keyPairs.Remove(sectionPair); this.tmpList.Remove(sectionPair); } }
internal void SetSetting(string sectionName, string settingName, string value) { IniParser.SectionPair sectionPair = new IniParser.SectionPair(); sectionPair.Section = sectionName; sectionPair.Key = settingName; if (string.IsNullOrEmpty(value)) { value = string.Empty; } if (this.keyPairs.ContainsKey(sectionPair)) { this.keyPairs[sectionPair] = value; } }
internal void AddSetting(string sectionName, string settingName, string settingValue) { IniParser.SectionPair sectionPair = new IniParser.SectionPair(); sectionPair.Section = sectionName; sectionPair.Key = settingName; if (settingValue == null) { settingValue = string.Empty; } if (this.keyPairs.ContainsKey(sectionPair)) { this.keyPairs.Remove(sectionPair); } if (this.tmpList.Contains(sectionPair)) { this.tmpList.Remove(sectionPair); } this.keyPairs.Add(sectionPair, settingValue); this.tmpList.Add(sectionPair); }