コード例 #1
0
ファイル: Languages.cs プロジェクト: diagonalwalnut/GodTools
        public async Task CreateLanguageFile(LanguageList languageList)
        {
            languageList.Languages = await GetLanguageListFromAPI(languageList.Languages);
            languageList.LastUpdated = DateTime.Now;

            SaveDataToFile(languageList, languageListFileName);
        }
コード例 #2
0
ファイル: Languages.cs プロジェクト: diagonalwalnut/GodTools
        public async Task UpdateLanguageList(LanguageList languageList)
        {
            LanguageList languageListCurrent = GetLanguageListFromFile(languageList);
            List<Language> languageListFromWeb = await GetLanguageListFromAPI(new List<Language>());

            languageListCurrent.Languages = AddLanguages(languageListCurrent.Languages, languageListFromWeb);
            languageListCurrent.Languages = DeleteLanguages(languageListCurrent.Languages, languageListFromWeb);
            languageListCurrent.Languages = await UpdateLanguages(languageListCurrent.Languages, languageListFromWeb);

            languageListCurrent.LastUpdated = DateTime.Now;

            SaveDataToFile(languageListCurrent, languageListFileName);
        }
コード例 #3
0
ファイル: Languages.cs プロジェクト: diagonalwalnut/GodTools
 public LanguageList GetLanguageListFromFile(LanguageList languageList)
 {
     languageList = RetrieveLocalData(languageListFileName);
     
     return languageList;
 }
コード例 #4
0
ファイル: Languages.cs プロジェクト: diagonalwalnut/GodTools
        private void SaveDataToFile(LanguageList languageList, string fileName)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            string jsonContents = JsonConvert.SerializeObject(languageList);

            File.WriteAllText(fileName, jsonContents);
        }
コード例 #5
0
ファイル: Languages.cs プロジェクト: diagonalwalnut/GodTools
        private LanguageList RetrieveLocalData(string fileName)
        {
            LanguageList languageList = new LanguageList();

            try
            {
                if (File.Exists(fileName))
                {
                    languageList = JsonConvert.DeserializeObject<LanguageList>(File.ReadAllText(fileName));

                    return languageList;
                }
                else
                {
                    //System.Diagnostics.Debug.WriteLine("Retrieve Language File: file does not exist");
                    return null;
                }
            }
            catch (Exception exception)
            {
                //System.Diagnostics.Debug.WriteLine("Language File: " + exception.Message);
                return null;
            }

            return languageList;
        }