public override void Command(MenuItem menuItem, string UserInput) { menuItem.Refresh(); ListenersMenuItem listenersMenu = ((ListenersMenuItem)menuItem); string[] commands = UserInput.Split(" "); if (commands.Length != 3 || commands[0].ToLower() != "rename") { menuItem.PrintInvalidOptionError(UserInput); return; } Listener listener = listenersMenu.Listeners.FirstOrDefault(L => L.Name.ToLower() == commands[1]); if (listener == null) { EliteConsole.PrintFormattedErrorLine("Listener with name: " + commands[1] + " does not exist."); menuItem.PrintInvalidOptionError(UserInput); } else if (listenersMenu.Listeners.Where(L => L.Name.ToLower() == commands[2].ToLower()).Any()) { EliteConsole.PrintFormattedErrorLine("Listener with name: " + commands[2] + " already exists."); menuItem.PrintInvalidOptionError(UserInput); } else { listener.Name = commands[2]; this.CovenantClient.ApiListenersPut(listener); } }
public override void Command(MenuItem menuItem, string UserInput) { menuItem.Refresh(); ListenersMenuItem listenersMenu = ((ListenersMenuItem)menuItem); EliteConsoleMenu typeMenu = new EliteConsoleMenu(EliteConsoleMenu.EliteConsoleMenuType.List, "Listener Types"); typeMenu.Columns.Add("ListenerName"); typeMenu.Columns.Add("Description"); listenersMenu.ListenerTypes.ToList().ForEach(L => { typeMenu.Rows.Add(new List <string> { L.Name, L.Description }); }); typeMenu.PrintEndBuffer = false; typeMenu.Print(); EliteConsoleMenu instanceMenu = new EliteConsoleMenu(EliteConsoleMenu.EliteConsoleMenuType.List, "Active Listeners"); instanceMenu.Columns.Add("Name"); instanceMenu.Columns.Add("TypeName"); instanceMenu.Columns.Add("Status"); instanceMenu.Columns.Add("BindAddress"); instanceMenu.Columns.Add("BindPort"); listenersMenu.Listeners.ToList().ForEach(L => { instanceMenu.Rows.Add(new List <string> { L.Name, listenersMenu.ListenerTypes.FirstOrDefault(LT => LT.Id == L.ListenerTypeId).Name, L.Status.ToString(), L.BindAddress, L.BindPort.ToString() }); }); instanceMenu.Print(); }