/// <summary> /// Overriden by inheriting classes to remove the message passed to the method. /// </summary> /// <param name="message">The message to remove from the collector.</param> /// <exception cref="ArgumentException">When the type of the message is not a message type of the collecotr.</exception> protected virtual void RemoveMessage(Message message) { if (message is T1 message1) { Messages1.TryRemove(message1.MessageDomain, out _); } else if (message is T2 message2) { Messages2.TryRemove(message2.MessageDomain, out _); } else { throw new ArgumentException($"There is no message type {message} in this collection.", nameof(message)); } }