ASP.NET Resourcemanager to read local .resx

ⅰ亾dé卋堺 提交于 2019-12-06 09:20:52
    public class ResxResourceManager : System.Resources.ResourceManager {
        public ResxResourceManager(string baseName, string resourceDir) {
            Type[] paramTypes = new Type[] { typeof(string), typeof(string), typeof(Type) };
            object[] paramValues = new object[] { baseName, resourceDir, typeof(ResXResourceSet) }; 

            Type baseType = GetType().BaseType;

            ConstructorInfo ci = baseType.GetConstructor(
                BindingFlags.Instance | BindingFlags.NonPublic,
                null, paramTypes, null);

            ci.Invoke(this, paramValues);
        }

    protected override string GetResourceFileName(CultureInfo culture) {
        string resourceFileName = base.GetResourceFileName(culture);
        return resourceFileName.Replace(".resources", ".resx");
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!