Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class WindowsRuntimeResourceManager : ResourceManager
private readonly ResourceLoader resourceLoader;
private static readonly Regex resourcesExtensionRegex = new Regex("\\.resources$");
private WindowsRuntimeResourceManager(string baseName, Assembly assembly)
: base(baseName, assembly)
this.resourceLoader = ResourceLoader.GetForViewIndependentUse(baseName);
public static void PatchResourceManagersInAssembly(Type typeInAssembly)
var assembly = typeInAssembly.GetTypeInfo().Assembly;
var resourceTypeNames = assembly.GetManifestResourceNames()
.Where(n => resourcesExtensionRegex.IsMatch(n))
.Select(n => resourcesExtensionRegex.Replace(n, string.Empty));
foreach(var typeName in resourceTypeNames)
var resourcesGeneratedType = assembly.GetType(typeName);
.First(f => f.IsStatic && f.FieldType == typeof(ResourceManager))
.SetValue(null, new WindowsRuntimeResourceManager(typeName, assembly));
public override string GetString(string name, CultureInfo culture)
return this.resourceLoader.GetString(name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.