Ejemplo n.º 1
0
        /// <summary>
        /// 获取应用配置的节点信息
        /// </summary>
        /// <param name="project">项目</param>
        /// <param name="key">键值</param>
        /// <returns>本地显示</returns>
        private static string GetItem(ProjectTypeEnum project, string key)
        {
            var lang            = LanguageCachedHelper.GetLang(project);
            var lanJsonResource = LocalizeCachedHelper.GetJsonResource(project);
            var value           = lanJsonResource[lang][key];

            return(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取JSON资源文件
        /// </summary>
        /// <param name="project">项目</param>
        /// <param name="jsonFile">json文件</param>
        static void ReadProjectJSONResourceFromFile(ProjectTypeEnum project)
        {
            var jsonFile = GetJSONFileNameByProject(project);

            try
            {
                var langJsonResource = new Dictionary <LangTypeEnum, Dictionary <string, string> >();
                foreach (var item in jsonFile)
                {
                    var jsonResource = ReadProjectJSONResourceFromFile(item.Value);
                    langJsonResource.Add(item.Key, jsonResource);
                }
                LocalizeCachedHelper.SetJsonResource(project, langJsonResource);
            }
            catch (System.Exception ex)
            {
                throw new ApplicationException(string.Format("An error occurred when reading json resource file, detai:{0}", ex.Message), ex);
            }
        }