/// <summary> /// Returns a resource string value /// and registers the property /// so It may be refreshed /// (by ResourceStringDecorator.Refresh()) after a current culture change /// </summary> /// <param name="d">The object which owns the property.</param> /// <param name="property">The property object. It may be a DependencyProperty (WPF property) or a PropertyInfo (CLR property).</param> /// <param name="assemblyName">The name of the assembly containing the baseName resx file for localization.</param> /// <param name="baseName">The resx file base name for localization.</param> /// <param name="resourceName">The name of the resource.</param> /// <returns>The resource string value.</returns> internal static string InitializeValue( DependencyObject d, object property, string assemblyName, string baseName, string resourceName) { string value = ""; ResourceSetManager rsm = GetManager(assemblyName, baseName); value = rsm.ResourceManager.GetString(resourceName); // Register (links) the property value to the ResourceSetManager.LocalizedObjects collection // so the ResourceStringCoordinator may refresh the property value // (by the Refresh() method) after a current culture change if (property is DependencyProperty) { DepPropResourceLink dprl = new DepPropResourceLink( d, resourceName, (DependencyProperty)property); rsm.LocalizedObjects.Add(dprl); } if (property is PropertyInfo) { ClrPropResourceLink cprl = new ClrPropResourceLink( d, resourceName, (PropertyInfo)property); rsm.LocalizedObjects.Add(cprl); } return(value); }
/// <summary> /// Returns a resource string value (without any registration). /// </summary> /// <param name="assemblyName">The name of the assembly containing the baseName resx file for localization.</param> /// <param name="baseName">The resx file base name for localization.</param> /// <param name="resourceName">The name of the resource.</param> /// <returns>The resource string value.</returns> internal static string GetString( string assemblyName, string baseName, string resourceName) { ResourceSetManager rsm = GetManager(assemblyName, baseName); return(rsm.ResourceManager.GetString(resourceName)); }
private static ResourceSetManager GetManager(string assemblyName, string baseName) { ResourceSetManager rsm; string fullBaseName = assemblyName + "." + baseName; if (_managers.ContainsKey(fullBaseName)) { rsm = _managers[fullBaseName]; } else { rsm = new ResourceSetManager( fullBaseName, assemblyName); } return(rsm); }