Exemplo n.º 1
0
        private void AddEventHandlers(object userForm, string formType)
        {
            var handlerMethods = ClassHelper.FindAnnotatedMethods <ItemEventHandlerAttribute>(userForm);

            foreach (var method in handlerMethods)
            {
                var attribute = method.GetAttribute <ItemEventHandlerAttribute>();
                var signature = ItemEventSignature.Create(method);

                if (attribute.BeforeAction)
                {
                    var action = BeforeAction <ItemEvent> .CreateNew(signature, method, userForm);

                    handlers.AddBefore(action);
                }
                else
                {
                    var action = AfterAction <ItemEvent> .CreateNew(signature, method, userForm);

                    handlers.AddAfter(action);
                }

                HandlerAdded(this, new HandlerAddedEventArgs(attribute.EventType, formType));
            }
        }
Exemplo n.º 2
0
        private bool IsSame(ItemEventSignature other)
        {
            if (BeforeAction != other.BeforeAction)
            {
                return(false);
            }

            if (EventType != other.EventType)
            {
                return(false);
            }

            if (!ItemId.Equals(other.ItemId))
            {
                return(false);
            }

            if (Modes.Count > 0 && !Modes.Intersect(other.Modes).Any())
            {
                return(false);
            }

            if (ColumnIds.Count > 0 && !ColumnIds.Intersect(other.ColumnIds).Any())
            {
                return(false);
            }

            return(true);
        }