Exemple #1
0
        public void SaveNewWordToFile(List <WordStuff> words, string newWord, string newDefinition)
        {
            var wordStatusHelper = new WordStatusHelper();

            if (wordStatusHelper.ContainsWord(newWord))
            {
                wordStatusHelper.Words.First(x => x.Word == newWord).ChangeDefinition(newDefinition);
            }
            else
            {
                words.Add(new WordStuff(newWord.ToLower(), newDefinition));
            }

            TextWriter writer = null;

            try
            {
                var json = JsonConvert.SerializeObject(words);
                writer = new StreamWriter("./new-word-list.json", false);
                writer.Write(json);
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }
        }
Exemple #2
0
 public WordValidationHelper()
 {
     this.wordStatusHelper = new WordStatusHelper();
 }