public ConsoleWindow() { Title = "Console"; Width = 480; Height = 240; var console = new Console { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; Content = console; // Print a message in the console. console.WriteLine("Enter 'help' to see all available commands."); // Register a new command 'close', which closes the ConsoleWindow. var closeCommand = new ConsoleCommand("close", "Close console.", _ => Close()); console.Interpreter.Commands.Add(closeCommand); }
private void AddHostCommand(IConsoleCommandHost commandHost, ConsoleCommand command) { ConsoleCommand localCommand = command; ConsoleCommand cmd = CreateScopedCommand(commandHost, command, localCommand); Console.Interpreter.Commands.Add(cmd); }
private ConsoleCommand CreateScopedCommand(IConsoleCommandHost commandHost, ConsoleCommand command, ConsoleCommand localCommand) { return new ConsoleCommand(commandHost.Name + "." + command.Name, command.Description, x => localCommand.Execute(x)); }