public static bool IsCategory(LingoWord w, string c) { if (w.Category == c) { return(true); } return(false); }
private List <LingoWord> GetDataFromXDocument() { // Load data from an XML file // TODO: Test and debug this for non-existant file; bad data format; whatever else XDocument xWords = XDocument.Load("initialLingoWords.xml"); // gather 'Item' elements from xDocument into an iterable collection IEnumerable <XElement> itemsXml = xWords.Descendants("Item"); // Create a generic list of Words from XML elements in the iterable itemsXml List <LingoWord> listWord = new List <LingoWord>(itemsXml.Count()); LingoWord item = null; foreach (XElement xItem in itemsXml) { item = new LingoWord() { Category = xItem.Element("Category").Value, Word = xItem.Element("Word").Value }; listWord.Add(item); } return(listWord); }