static void Main(string[] args) { XLibDocument document = new XLibDocument(); document.Open(""); Console.WriteLine("Standard file opened"); UIHelpers.Flow(document); }
public static void Flow(XLibDocument document) { document = (document == null) ? new XLibDocument() : document; while (true) { Console.WriteLine("What to do next? ( 0 - open file, 1 - search, 2 - save" + " 3 - show all, 4 - add, 5 - remove, 6 - exit)"); string variant = Console.ReadLine(); Console.Clear(); switch (variant) { case "0": Console.WriteLine("Enter path:"); document.Open(Console.ReadLine(), prevIfFail: true); break; case "1": UIHelpers.Searching(document); break; case "2": Console.WriteLine("Enter filename and path"); document.Save(Console.ReadLine()); break; case "3": try { UIHelpers.ShowResults(document.Books); } catch (ArgumentException) { document = new XLibDocument(); Console.WriteLine("Current document flushed"); } break; case "4": document = UIHelpers.AddBook(document); Console.WriteLine("Added"); break; case "5": Console.WriteLine("Find which books to remove"); document.RemoveBooks(UIHelpers.Searching(document)); Console.WriteLine("Removed successfully"); break; case "6": return; default: Console.WriteLine("Wrong input - please open a number from 0 to 4 or 5 to exit"); break; } } }