(3dc4135ce) v0.9.5.1
This commit is contained in:
@@ -110,5 +110,60 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ICollection<string> ParseCommaSeparatedStringToCollection(string input, ICollection<string> texts = null, bool convertToLowerInvariant = true)
|
||||
{
|
||||
if (texts == null)
|
||||
{
|
||||
texts = new HashSet<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
texts.Clear();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
foreach (string value in input.Split(','))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) { continue; }
|
||||
if (convertToLowerInvariant)
|
||||
{
|
||||
texts.Add(value.ToLowerInvariant());
|
||||
}
|
||||
else
|
||||
{
|
||||
texts.Add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return texts;
|
||||
}
|
||||
|
||||
public static ICollection<string> ParseSeparatedStringToCollection(string input, string[] separators, ICollection<string> texts = null, bool convertToLowerInvariant = true)
|
||||
{
|
||||
if (texts == null)
|
||||
{
|
||||
texts = new HashSet<string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
texts.Clear();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
foreach (string value in input.Split(separators, StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (convertToLowerInvariant)
|
||||
{
|
||||
texts.Add(value.ToLowerInvariant());
|
||||
}
|
||||
else
|
||||
{
|
||||
texts.Add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return texts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user