コード例 #1
0
        public void AddAfter(AfterAction <T> action)
        {
            if (after.Exists(a => a.IsSame(action)))
            {
                throw EventHandlerAlreadyExistsException.CreateFromKey(action.Name);
            }

            after.Add(action);
        }
コード例 #2
0
        public void AddBefore(BeforeAction <T> action)
        {
            if (before.Exists(a => a.IsSame(action)))
            {
                throw EventHandlerAlreadyExistsException.CreateFromKey(action.Name);
            }

            before.Add(action);
        }
コード例 #3
0
        /// <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);
        }