Is there a way to search a WPF application for resources?
I have added many images to an app and want to perform search i.e. MS*.jpg
etc., Is this possible?
If I could create a list of all the resources, that would surely be helpful as well, but I don't want it to cost to much performance (I will make it lazy loaded tho).
Once you have them all under an IEnumerable<string>
the search job is hell of a lot easier.
public static IEnumerable<object> GetResourcePaths()
{
var culture = System.Threading.Thread.CurrentThread.CurrentCulture;
var resourceName = CurrentAssembly.GetName().Name + ".g";
var resourceManager = new ResourceManager(resourceName, CurrentAssembly);
try
{
var resourceSet = resourceManager.GetResourceSet(culture, true, true);
foreach (DictionaryEntry resource in resourceSet)
{
yield return resource.Key;
}
}
finally
{
resourceManager.ReleaseAllResources();
}
}
Answer taken from here