Last active
December 20, 2015 01:49
-
-
Save cjlotz/6051474 to your computer and use it in GitHub Desktop.
PivotViewerResourceManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PivotViewerResourceManager : ResourceManager | |
{ | |
public const string PivotViewerResourcePrefix = "MSPivot"; | |
private PivotViewerResourceManager(IResourceProvider provider) : base("System.Windows.Controls.Pivot.Properties.Resources", typeof(PivotViewer).Assembly) | |
{ | |
ResourceProvider = provider; | |
} | |
private IResourceProvider ResourceProvider { get; set; } | |
public override string GetString(string name, CultureInfo culture) | |
{ | |
string resourceString = null; | |
// First attempt reading the "MSPivot" prefixed resources from any external provider | |
if (ResourceProvider != null) | |
resourceString = ResourceProvider.GetString(PivotViewerResourcePrefix + name, culture); | |
// If no external resource value found, read from the base MS pivot viewer resource file | |
if (string.IsNullOrEmpty(resourceString)) | |
resourceString = base.GetString(name, culture); | |
return resourceString; | |
} | |
public static void InjectResourceManager(IResourceProvider provider) | |
{ | |
Check.ArgumentNotNull(provider, "provider"); | |
Type resources = typeof(PivotViewer).Assembly.GetType("System.Windows.Controls.Pivot.Properties.Resources"); | |
FieldInfo fieldInfo = resources.GetField("resourceMan", BindingFlags.Static | BindingFlags.NonPublic); | |
fieldInfo.SetValue(null, new PivotViewerResourceManager(provider)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment