# HG changeset patch # User IBBoard # Date 1238098327 0 # Node ID 848e7b151d3c96a97dd473d279a6d781e702fa69 # Parent 5b0052b5585f28fc7f8b2ea35cb1f54b2283c753 Re #17 - Make INI section names and keys case insensitive * Add ToLower() when adding sections and lines to dictionaries * Add ToLower() when getting sections and lines from dictionaries diff -r 5b0052b5585f -r 848e7b151d3c IniFile.cs --- a/IniFile.cs Sat Feb 21 11:01:04 2009 +0000 +++ b/IniFile.cs Thu Mar 26 20:12:07 2009 +0000 @@ -34,9 +34,11 @@ /// public void AddSection(IniSection section) { - if (!HasSection(section.Name)) + string sectionName = section.Name.ToLower(); + + if (!HasSection(sectionName)) { - sections.Add(section.Name, section); + sections.Add(sectionName, section); } else { @@ -62,7 +64,7 @@ get { IniSection section = null; - sections.TryGetValue(sectionName.Trim(), out section); + sections.TryGetValue(sectionName.Trim().ToLower(), out section); if (section == null) { @@ -84,7 +86,7 @@ /// public bool HasSection(string sectionName) { - return sections.ContainsKey(sectionName.Trim()); + return sections.ContainsKey(sectionName.Trim().ToLower()); } /// diff -r 5b0052b5585f -r 848e7b151d3c IniSection.cs --- a/IniSection.cs Sat Feb 21 11:01:04 2009 +0000 +++ b/IniSection.cs Thu Mar 26 20:12:07 2009 +0000 @@ -80,7 +80,7 @@ get { IniKeyValuePairLine keyValuePair = null; - values.TryGetValue(key.Trim(), out keyValuePair); + values.TryGetValue(key.Trim().ToLower(), out keyValuePair); return keyValuePair; } } @@ -96,7 +96,7 @@ if (iniLine is IniKeyValuePairLine) { IniKeyValuePairLine keyValuePair = (IniKeyValuePairLine)iniLine; - string key = keyValuePair.Key; + string key = keyValuePair.Key.ToLower(); if (!values.ContainsKey(key)) {