private IConfigurationSection GetSection(string sectionData) { IConfigurationSection section = new ConfigurationSection("Temp"); string[] lines = sectionData.Split(new[] { Environment.NewLine }, StringSplitOptions.None); foreach (string line in lines) { string workingLine = line; if (line.Contains(Comment)) { workingLine = line.Substring(0, line.IndexOf(Comment, StringComparison.OrdinalIgnoreCase)); } if (workingLine.StartsWith("[", StringComparison.OrdinalIgnoreCase) && workingLine.EndsWith("]", StringComparison.OrdinalIgnoreCase)) { string sectionName = workingLine.Substring(1, workingLine.Length - 2).Trim(); if (string.IsNullOrEmpty(sectionName)) { throw new InvalidOperationException(Text.NoEmptySectionNames); } section.Name = sectionName; continue; } string[] pair = workingLine.Split(new[] { Delimiter }, StringSplitOptions.None); string key = pair[0].Trim(); string value = (pair.Length == 2 ? pair[1].Trim() : String.Join(Delimiter, pair.Skip(1).ToArray())); if (string.IsNullOrEmpty(key)) { continue; } section.Set(key, value); } return(section); }