public void AddAfter(AfterAction <T> action) { if (after.Exists(a => a.IsSame(action))) { throw EventHandlerAlreadyExistsException.CreateFromKey(action.Name); } after.Add(action); }
public void AddBefore(BeforeAction <T> action) { if (before.Exists(a => a.IsSame(action))) { throw EventHandlerAlreadyExistsException.CreateFromKey(action.Name); } before.Add(action); }
/// <summary> /// Initializes a new instance of the <see cref="EventHandlerAlreadyExistsException" /> class. /// </summary> /// <param name="key">The key of the event handler.</param> public static EventHandlerAlreadyExistsException CreateFromKey(string key) { var exception = new EventHandlerAlreadyExistsException($"{key} is already registered."); return(exception); }