public void ImportExclusions(string file)
{
// add exclusions
if (!string.IsNullOrEmpty(file) && !string.IsNullOrWhiteSpace(file) && File.Exists(file))
{
Regex regex;
if (SplitType == StringSplitType.Word)
regex = new Regex(@"\w+", RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.IgnoreCase);
else
regex = new Regex(@"\w", RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.IgnoreCase);
List<string> exclusionList = new List<string>();
using (StreamReader sr = File.OpenText(file))
{
string line;
while ((line = sr.ReadLine()) != null)
{
var match = regex.Match(line);
// found something not already in list...
if (match.Success && !exclusionList.Contains(match.Value.Trim().ToUpperInvariant()))
exclusionList.Add(match.Value.Trim().ToUpperInvariant());
}
}
Exclude = exclusionList.OrderBy(s => s).ToArray();
}
else
Exclude = new string[] { };
}