diff --git a/src/Microsoft.Framework.Configuration.Ini/Ini/IniConfigurationSource.cs b/src/Microsoft.Framework.Configuration.Ini/Ini/IniConfigurationSource.cs index 6565e3f..ec9cf29 100644 --- a/src/Microsoft.Framework.Configuration.Ini/Ini/IniConfigurationSource.cs +++ b/src/Microsoft.Framework.Configuration.Ini/Ini/IniConfigurationSource.cs @@ -110,7 +110,7 @@ namespace Microsoft.Framework.Configuration.Ini if (line[0] == '[' && line[line.Length - 1] == ']') { // remove the brackets - sectionPrefix = line.Substring(1, line.Length - 2) + ":"; + sectionPrefix = line.Substring(1, line.Length - 2) + Constants.KeyDelimiter; continue; } diff --git a/src/Microsoft.Framework.Configuration.Json/Json/JsonConfigurationFileParser.cs b/src/Microsoft.Framework.Configuration.Json/Json/JsonConfigurationFileParser.cs index fe1516f..58f9101 100644 --- a/src/Microsoft.Framework.Configuration.Json/Json/JsonConfigurationFileParser.cs +++ b/src/Microsoft.Framework.Configuration.Json/Json/JsonConfigurationFileParser.cs @@ -101,13 +101,13 @@ namespace Microsoft.Framework.Configuration.Json private void EnterContext(string context) { _context.Push(context); - _currentPath = string.Join(":", _context.Reverse()); + _currentPath = string.Join(Constants.KeyDelimiter, _context.Reverse()); } private void ExitContext() { _context.Pop(); - _currentPath = string.Join(":", _context.Reverse()); + _currentPath = string.Join(Constants.KeyDelimiter, _context.Reverse()); } } } diff --git a/src/Microsoft.Framework.Configuration/ConfigurationKeyComparer.cs b/src/Microsoft.Framework.Configuration/ConfigurationKeyComparer.cs index 4cb57a5..f040f4f 100644 --- a/src/Microsoft.Framework.Configuration/ConfigurationKeyComparer.cs +++ b/src/Microsoft.Framework.Configuration/ConfigurationKeyComparer.cs @@ -8,14 +8,14 @@ namespace Microsoft.Framework.Configuration { public class ConfigurationKeyComparer : IComparer { - private const char Separator = ':'; - + private static readonly string[] _keyDelimiterArray = new[] { Constants.KeyDelimiter }; + public static ConfigurationKeyComparer Instance { get; } = new ConfigurationKeyComparer(); public int Compare(string x, string y) { - var xParts = x?.Split(Separator) ?? new string[0]; - var yParts = y?.Split(Separator) ?? new string[0]; + var xParts = x?.Split(_keyDelimiterArray, StringSplitOptions.RemoveEmptyEntries) ?? new string[0]; + var yParts = y?.Split(_keyDelimiterArray, StringSplitOptions.RemoveEmptyEntries) ?? new string[0]; // Compare each part until we get two parts that are not equal for (int i = 0; i < Math.Min(xParts.Length, yParts.Length); i++)