/* * Usage: debug mode already has arguments set. * If running from console: * 1) TextServiceApp "input text" * 2) TextServiceApp -f "TextFile1.txt" (predefined files in Texts\ folder) * 3) TextServiceApp -t "input text" (optional, but same as first) */ private static void Main(string[] args) { if (args.Length > 1 && !"-t,-f".Contains(args[0])) { throw new ArgumentException("Missing arguments", "-t or -f"); } string text = null; switch (args[0]) { case "-t": text = args[1]; break; case "-f": text = File.ReadAllText(args[1]); break; default: text = args[0]; break; } ConsoleKeyInfo selection; do { Console.WriteLine("ENTER SORTOPTION:"); Console.WriteLine("1) Character"); Console.WriteLine("2) Word"); Console.WriteLine("3) Line"); selection = Console.ReadKey(true); }while (selection.Key != ConsoleKey.D1 && selection.Key != ConsoleKey.D2 && selection.Key != ConsoleKey.D3); var sort = "Character"; switch (selection.Key) { case ConsoleKey.D2: sort = "Word"; break; case ConsoleKey.D3: sort = "Line"; break; } var _textService = new TextService.TextService(); Console.WriteLine(); Console.WriteLine("PROCESSING: {0}", text); Console.WriteLine(); Console.WriteLine("SORTED: {0}", _textService.Sort(text, sort)); Console.WriteLine(); Console.WriteLine("STATISTICS: {0}", _textService.GenerateStatistics(text)); Console.Read(); }
public TextController(TextService.TextService textService) { _textService = textService; }