protected void ShowDelListener() { Console.WriteLine("Please enter the ID of the listener you want to delete:\r\n (use the 'listlisteners' command to show all the listener IDs)"); string id = Console.ReadLine(); if (id != "") { try { ListenEntry le = new ListenEntry(); le.guid = new Guid(id); if (!Listeners.Contains(le)) { Console.WriteLine("Specified ID not found in list!"); return; } else { this[Listeners.IndexOf(le)].Dispose(); Listeners.Remove(le); } } catch { Console.WriteLine("Invalid ID tag!"); return; } Console.WriteLine("Listener removed from the list."); } }
public void AddListener(Listener newItem) { if (newItem == null) { throw new ArgumentNullException(); } ListenEntry le = new ListenEntry(); le.listener = newItem; le.guid = Guid.NewGuid(); while (Listeners.Contains(le)) { le.guid = Guid.NewGuid(); } Listeners.Add(le); Console.WriteLine(newItem.ToString() + " started."); }