Mercurial > repos > IBBoard.Ini
changeset 10:848e7b151d3c
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
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 26 Mar 2009 20:12:07 +0000 |
parents | 5b0052b5585f |
children | 1c36044114a3 |
files | IniFile.cs IniSection.cs |
diffstat | 2 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ /// </param> 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 @@ /// </returns> public bool HasSection(string sectionName) { - return sections.ContainsKey(sectionName.Trim()); + return sections.ContainsKey(sectionName.Trim().ToLower()); } /// <summary>
--- 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)) {