public static IEnumerable <EventRaiserDefinition> CreateRaiserDefinitionsForRow(IRowButtons rowButtons,
                                                                                        int index)
        {
            void SetMoveUpEventData(EventBase @event)
            {
                SetMoveEventData(@event as MoveItemEvent, MoveItemEvent.MoveDirection.Up);
            }

            void SetMoveDownEventData(EventBase @event)
            {
                SetMoveEventData(@event as MoveItemEvent, MoveItemEvent.MoveDirection.Down);
            }

            void SetRemoveEventData(EventBase @event)
            {
                SetItemEventData <RemoveItemEvent>(@event as RemoveItemEvent);
            }

            void SetMoveEventData(MoveItemEvent @event, MoveItemEvent.MoveDirection direction)
            {
                SetItemEventData <MoveItemEvent>(@event);
                @event.Direction = direction;
            }

            void SetItemEventData <T>(ItemEventBase <T> @event) where T : ItemEventBase <T>, new()
            {
                if (@event is null)
                {
                    throw new ArgumentException(nameof(@event), $"Expected type: {typeof(T)}");
                }

                @event.Index = index;
            }

            return(new List <EventRaiserDefinition>
            {
                EventRaiserDefinition.Create <MoveItemEvent>(rowButtons.MoveUp,
                                                             SetMoveUpEventData),
                EventRaiserDefinition.Create <MoveItemEvent>(rowButtons.MoveDown,
                                                             SetMoveDownEventData),
                EventRaiserDefinition.Create <RemoveItemEvent>(rowButtons.RemoveItem,
                                                               SetRemoveEventData)
            });
        }
        public static IEnumerable <EventRaiserDefinition> CreateRaiserDefinitions(IOuterControls controls)
        {
            void SetExtraEventData(EventBase obj)
            {
                if (!(obj is AddItemEvent evt))
                {
                    throw new ArgumentException($"Expected type: {typeof(AddItemEvent)}");
                }

                evt.Item = controls.AddObjectField.value;
            }

            return(new List <EventRaiserDefinition>
            {
                EventRaiserDefinition.Create <ClearListRequestedEvent>(controls.ClearList),
                EventRaiserDefinition.Create <ClearListEvent>(controls.ClearListConfirm),
                EventRaiserDefinition.Create <ClearListCancelledEvent>(controls.ClearListCancel),
                EventRaiserDefinition.Create <AddItemEvent>(controls.Add),
                EventRaiserDefinition.Create <AddItemEvent>(controls.AddObjectField, SetExtraEventData)
            });
        }