combine string resource files

Jul 25, 2014 at 6:57 AM
Hi,

I am working on Universal app(with Prism). Here is my scenario.
I have a string resource file in following projects:
1) Windows - Resources.resw - This file has windows specific string resources
2) WindowsPhone - Resources.resw - This file has phone specific string resources
3) Shared - SharedResources.resw - This file has string resources which are common between windows and phone.

Now, How can I make ResourceLoader to search resources in "SharedResources.resw" and "Resources.resw" both the files?

Any suggestions?

Thanks in advance.
Jul 28, 2014 at 9:41 AM
I have extended the ResourceLoader class as following:
public class ResourceLoaderEx : IResourceLoaderEx
{
    //This method is used when the PCL contains .resx file instead of .resw.
    public string GetString(string resource,  string baseName, Assembly assembly)         {
            ResourceManager resourceManager = new ResourceManager(baseName, assembly);
            return resourceManager.GetString(resource);
    }

     public string GetString(string resource)
    {
        ResourceLoader resourceLoader;
        if (resource.Contains("\\"))
        {
            resourceLoader = ResourceLoader.GetForCurrentView(resource.Substring(0, resource.LastIndexOf("\\")));
            resource = resource.Substring(resource.LastIndexOf("\\") + 1);
        }
        else
        {
            resourceLoader = ResourceLoader.GetForCurrentView();
        }
        return resourceLoader.GetString(resource);
    }
}
This class covers following scenarios:
var windowsSpecificResource = resourceLoader.GetString(@"windows"); // This will fetch the resource from Resources.resw file
var sharedResource = resourceLoader.GetString(@"SharedResources\testforshared"); // This will fetch the resource from the SharedResources.resw file
var pclResource = resourceLoader.GetString("SaveErrorMessage", "Contoso.UILogic.Strings.Resources", typeof(Strings.Resources).GetTypeInfo().Assembly); // This will fetch the resource from Resources.resx file which is in my UILogic project.


Any comments?