예제 #1
0
        public void Convert()
        {
            VmWordCollection inWords = GetWordsCollection(inWordsJsonPath);

            VmCurrentWord[] currentWords = GetCurrentWords(curentWordsJsonPath);
            VmWord[]        outWords     = new VmWord[inWords.Word.Length];

            for (int i = 0; i < outWords.Length; i++)
            {
                outWords[i] = new VmWord
                {
                    Name_en                 = inWords.Word[i].Items[0].word,
                    Name_ru                 = currentWords?.FirstOrDefault(p => p.Name_ru == inWords.Word[i].Items[0].word).Name_en,
                    FourDaysLearnPhase      = false,
                    LearnDay                = 0,
                    RepeatIterationNum      = 0,
                    NextRepeatDate          = DateTime.Today,
                    DailyReapeatCountForEng = 0,
                    DailyReapeatCountForRus = 0
                                              //Dictors_en = null,
                                              //Dictors_ru = new VmDictor[getDictors.lenght]
                };
            }

            SaveOutWords(outWords, outWordsPath);
        }
예제 #2
0
        static VmWordCollection GetWordsCollection(string jsonPath)
        {
            VmWordCollection words;

            if (!File.Exists(jsonPath))
            {
                Console.WriteLine("File doesn't exist, path: {0}", jsonPath);
                throw new ArgumentNullException(jsonPath);
            }
            // read file into a string and deserialize JSON to a type
            VmWordCollection wordCollection = JsonConvert.DeserializeObject <VmWordCollection>(File.ReadAllText(jsonPath));

            // deserialize JSON directly from a file
            using (StreamReader file = File.OpenText(jsonPath))
            {
                JsonSerializer serializer = new JsonSerializer();
                words = (VmWordCollection)serializer.Deserialize(file, typeof(VmWordCollection));
            }
            return(words);
        }