+Resources

This commit is contained in:
2025-10-08 09:53:53 +08:00
parent 284e764345
commit c1bd6bbabd
9 changed files with 2855 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
using System.Resources;
namespace Flee.Resources
{
internal class FleeResourceManager
{
private Dictionary<string, ResourceManager> MyResourceManagers;
private static FleeResourceManager OurInstance = new FleeResourceManager();
private FleeResourceManager()
{
MyResourceManagers = new Dictionary<string, ResourceManager>(StringComparer.OrdinalIgnoreCase);
}
private ResourceManager GetResourceManager(string resourceFile)
{
lock (this)
{
ResourceManager rm = null;
if (MyResourceManagers.TryGetValue(resourceFile, out rm) == false)
{
Type t = typeof(FleeResourceManager);
rm = new ResourceManager(string.Format("{0}.{1}", t.Namespace, resourceFile), t.Assembly);
MyResourceManagers.Add(resourceFile, rm);
}
return rm;
}
}
private string GetResourceString(string resourceFile, string key)
{
ResourceManager rm = this.GetResourceManager(resourceFile);
return rm.GetString(key);
}
public string GetCompileErrorString(string key)
{
return this.GetResourceString("CompileErrors", key);
}
public string GetElementNameString(string key)
{
return this.GetResourceString("ElementNames", key);
}
public string GetGeneralErrorString(string key)
{
return this.GetResourceString("GeneralErrors", key);
}
public static FleeResourceManager Instance
{
get { return OurInstance; }
}
}
}