Я предлагаю организовать шаблоны в словарь и избавиться от switch ... case
:
//TODO: I've hardcoded the patterns, but you may well want to generate them:
// s_Patterns = MyFileTypes.ToDictionary(t => t.Name, $"^{t.Name.ToUpper()}_");
private static Dictionary<string, string> s_Patterns = new Dictionary<string, string>() {
{"pd", "^PD_"},
{"fx", "^FX_"},
};
, тогда вы можете легко использовать их:
if (s_Patterns.TryGetValue(fileType, out var pattern))
fileList = fileList.Where(x => Regex.IsMatch(x.FileName, pattern));
else
System.Diagnostics.Debug.WriteLine("File type not valid.");