Пример #1
0
        /// <summary>
        /// 获取资源
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public Resources GetResources(string filePath)
        {
            var resources = new Resources();

            if (File.Exists(filePath))
            {
                resources = ResourcesSerializer.DeSerialize(filePath);
                resources.CreateIndex();
            }
            return(resources);
        }
Пример #2
0
        /// <summary>
        /// 获取语言
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public Hashtable GetLanguages(string path)
        {
            var hashtable     = new Hashtable();
            var directoryInfo = new DirectoryInfo(path);

            if (!directoryInfo.Exists)
            {
                return(hashtable);
            }
            var fileInfo = directoryInfo.GetFiles();

            foreach (var t in fileInfo)
            {
                var resources = ResourcesSerializer.DeSerialize(t.FullName);
                hashtable.Add(resources.Language, resources.DisplayName);
            }
            return(hashtable);
        }
Пример #3
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="filePath"></param>
        public void Init(string filePath)
        {
            _folderPath = filePath;
            var directoryInfo = new DirectoryInfo(filePath);

            LanguageResources.Clear();
            if (!directoryInfo.Exists)
            {
                return;
            }
            var fileInfo = directoryInfo.GetFiles();

            foreach (var t in fileInfo)
            {
                var resources = ResourcesSerializer.DeSerialize(t.FullName);
                resources.CreateIndex();
                LanguageResources.Add(resources.Language, resources);
            }
        }
Пример #4
0
 /// <summary>
 /// 序列化
 /// </summary>
 /// <param name="resources"></param>
 /// <param name="filePath"></param>
 public void Serialize(Resources resources, string filePath)
 {
     ResourcesSerializer.Serialize(filePath, resources);
 }