个人资料

跳过导航链接首页 > 博客列表 > 博客正文

UWP多语言帮助类

分类:
    public static class AppResources
    {
        private static ResourceLoader CurrentResourceLoader
        {
            get { return _loader ?? (_loader = ResourceLoader.GetForCurrentView("Resources")); }
        }

        private static ResourceLoader _loader;
        private static readonly Dictionary<string, string> ResourceCache = new Dictionary<string, string>();

        public static string GetString(string key)
        {
            string s;
            if (ResourceCache.TryGetValue(key, out s))
            {
                return s;
            }
            else
            {
                s = CurrentResourceLoader.GetString(key);
                ResourceCache[key] = s;
                return s;
            }
        }




    }
songshizhao
最初发表2021/6/1 10:22:05 最近更新2021/6/1 10:22:05 681
为此篇作品打分
10
   评论