public static ResourceManager ForAssembly(Assembly assembly) { if (ResourceManagers.ContainsKey(assembly.FullName)) { return(ResourceManagers[assembly.FullName]); } var resourceManager = new ResourceManager(assembly); ResourceManagers.Add(assembly.FullName, resourceManager); return(resourceManager); }
//======================================================================================== // LoadResourceManager() // Assumes that the resource manager for the specified baseName has not yet been // loaded. Loads the resource manager and seeds it with the resource set associated // with the current thread culture. //======================================================================================== private ResourceManager LoadResourceManager(string baseName, string resourceNs) { string resourceBaseName; if ((resourceNs == null) || (resourceNs.Length == 0)) { resourceBaseName = baseName; } else { resourceBaseName = baseName + "." + resourceNs; } if (managers.ContainsKey(resourceBaseName)) { return(managers[resourceBaseName]); } ResourceManager rm; string filnam = rootPath + "\\" + baseName + ".dll"; if (!File.Exists(filnam)) { filnam = rootPath + "\\" + baseName + ".exe"; } try { Assembly assembly = Assembly.LoadFrom(filnam); rm = new ResourceManager(resourceBaseName, assembly); managers.Add(resourceBaseName, rm); } catch (Exception exc) { throw new Exception("Error loading resource assembly " + filnam + ". Exception: [" + exc.Message + "]"); } return(rm); }