private static void LoadProfileNames()
{
try
{
IEnumerable<string> profileFiles = Directory.GetFiles(PROFILE_FOLDER).Where(x => x.EndsWith(PROFILE_EXTENSION));
foreach (string profileFile in profileFiles)
{
XElement profileNode = XDocument.Load(profileFile).Root;
if (profileNode == null) continue;
string name = profileNode.Element("name")?.Value;
string id = profileNode.Element("id")?.Value;
if (!string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(id) && !_profileNameMapping.ContainsKey(name)) // I think duplicates are an error case
_profileNameMapping.Add(name, id);
}
}
// ReSharper disable once CatchAllClause - This shouldn't happen but you never know ...
catch
{
_profileNameMapping.Clear();
}
}