Skip to content

Commit

Permalink
improving array value-related methods in ConfigParser class
Browse files Browse the repository at this point in the history
  • Loading branch information
salaros committed Jun 17, 2018
1 parent 801fbf7 commit ffad542
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/ConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public virtual byte[] GetValue(string sectionName, string keyName, byte[] defaul
/// <param name="defaultValue">The default array value.</param>
/// <returns></returns>
/// <exception cref="ConfigParserException"></exception>
public virtual string[] GetValue(string sectionName, string keyName, string[] defaultValue = null)
public virtual string[] GetValue(string sectionName, string keyName, string[] defaultValue)
{
var arrayRaw = GetRawValue(sectionName, keyName, string.Empty);
if (string.IsNullOrWhiteSpace(arrayRaw))
Expand All @@ -244,6 +244,18 @@ public virtual string[] GetValue(string sectionName, string keyName, string[] de
.ToArray();
}

/// <summary>
/// Gets the array value.
/// </summary>
/// <param name="sectionName">Name of the section.</param>
/// <param name="keyName">Name of the key.</param>
/// <param name="defaultValue">The default value.</param>
/// <returns></returns>
public virtual string[] GetArrayValue(string sectionName, string keyName, string[] defaultValue = null)
{
return GetValue(sectionName, keyName, defaultValue);
}

/// <summary>
/// Checks if value the is an array.
/// </summary>
Expand All @@ -256,8 +268,8 @@ public virtual bool ValueIsArray(string sectionName, string keyName)
if (string.IsNullOrWhiteSpace(arrayRaw))
return false;

var values = arrayRaw.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
return values.Any();
var values = arrayRaw.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
return values.Any() && string.IsNullOrWhiteSpace(values.First());
}

#endregion
Expand Down

0 comments on commit ffad542

Please sign in to comment.