public IEnumerable <XElement> Filter(string by, string value) { IEnumerable <XElement> collection = null; if (document != null) { collection = document.Root.Descendants("book"); } return(XLibDocument.Filter(collection, by, value)); }
public static IEnumerable <XElement> Searching(XLibDocument document) { IEnumerable <XElement> elements = null; while (true) { if (elements != null) { Console.WriteLine("Enter f to filter results, or e to exit"); var control = Console.ReadLine().Trim().ToLower(); switch (control) { case "e": return(elements); case "f": break; default: continue; } Console.WriteLine("What do you want to filter by? (author, tiltle, price)"); } else { Console.WriteLine("What do you want to search by? (author, tiltle, price)"); } string by = Console.ReadLine(); Console.WriteLine("What should the {0} be?", by); string value = Console.ReadLine(); if (elements == null) { elements = document.Filter(by, value); } else { elements = XLibDocument.Filter(elements, by, value); } ShowResults(elements); } }