private string ReadFile(ICharacterReader cr) { char c = ' '; string myText = ""; int index = 0; do { c = cr.SimpleCharacterReader(index); myText += c; index++; }while (c != '¬'); cr.Dispose(); return(myText); }
} //accessor for myDictionary mainly used for the testing /// <summary> /// Constructor accepting ICharReader interface object /// Gets tje word list from the reader, as long as there is text in the file /// Adds the words to the dictionary if they dont exist /// If the word has already been added, it adds 1 to the value of the word /// </summary> /// <param name="cr"></param> public ReadManager(ICharacterReader cr) { string text = ReadFile(cr); this.wordList = cr.MyListOfWords; for (int i = 0; i < wordList.Count; i++) { if (myDictionary.ContainsKey(wordList[i])) { myDictionary[wordList[i]]++; } else { myDictionary.Add(wordList[i], 1); } } cr.Dispose(); }
public void Dispose() { _reader.Dispose(); }