static async Task StartBot() { using (var container = new UnityContainer()) { FuhrerContext.Init(); await BL.Bootstrap.RegisterTypesAsync(container); Data.Bootstrap.RegisterTypes(container); //telegram UI var commandReader = new CommandReader(container); await commandReader.Execute(); //console UI /*System.Console.WriteLine("Input command in format \"<command> <user name> <chat title>\""); * var commandLine = string.Empty; * while (string.IsNullOrEmpty(commandLine) || !commandLine.Equals("exit", StringComparison.OrdinalIgnoreCase)) * { * commandLine = System.Console.ReadLine(); * if (string.IsNullOrEmpty(commandLine)) continue; * var commandLineArray = commandLine.Split(' '); * if (commandLineArray.Length < 2) * { * System.Console.WriteLine("Command arguments requiered"); * continue; * } * * var command = commandLineArray[0]; * ICommand cmd; * try * { * cmd = container.Resolve<ICommand>(command.ToLower()); * } * catch * { * System.Console.WriteLine("Incorrect command."); * continue; * } * * try * { * var cmdResult = await cmd.Execute(commandLine.TrimStart(command + " ")); * System.Console.WriteLine(cmdResult.Message); * while (!cmdResult.Success) * { * cmdResult = await cmdResult.NextAction(System.Console.ReadLine()); * System.Console.WriteLine(cmdResult.Message); * } * } * catch (Exception ex) * { * System.Console.WriteLine(ex.Message); * } * }*/ } }
private static async void WorkerThread() { try { using (var container = new UnityContainer()) { //FuhrerContext.Init(); await BL.Bootstrap.RegisterTypesAsync(container); Data.Bootstrap.RegisterTypes(container); var commandReader = new CommandReader(container); await commandReader.Execute(); } } catch (Exception ex) { Log.Error("Error in CommandReader", ex); WorkerThread(); } }