public static IEnumerable<SelectCategory> LoadCategories(string type) {
return FilesStorage.Instance.GetContentDirectoryFiltered(@"*.json", type).Select(x => x.Filename).SelectMany(x => {
try {
return JsonConvert.DeserializeObject<SelectCategory[]>(File.ReadAllText(x));
} catch (Exception e) {
Logging.Warning($"Cannot load file {Path.GetFileName(x)}: {e}");
return new SelectCategory[0];
}
}).Select(x => {
x.Icon = FilesStorage.Instance.GetContentFile(type, x.Icon ?? x.DisplayName + @".png").Filename;
return x;
});
}
}