Ответ 1
Вы можете перечислить атрибуты AssemblyAssociatedContentFile
, определенные на сборке:
var resourceUris = Assembly.GetEntryAssembly()
.GetCustomAttributes(typeof(AssemblyAssociatedContentFileAttribute), true)
.Cast<AssemblyAssociatedContentFileAttribute>()
.Select(attr => new Uri(attr.RelativeContentFilePath));
Вы также можете проверить эту страницу для способа перечисления ресурсов BAML.
UPDATE: на самом деле решение выше работает только для файлов Content. Метод belows возвращает все имена ресурсов (включая ресурсы BAML, изображения и т.д.):
public static string[] GetResourceNames()
{
var asm = Assembly.GetEntryAssembly();
string resName = asm.GetName().Name + ".g.resources";
using (var stream = asm.GetManifestResourceStream(resName))
using (var reader = new System.Resources.ResourceReader(stream))
{
return reader.Cast<DictionaryEntry>().Select(entry => (string)entry.Key).ToArray();
}
}