Beispiel #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));
            }
        }
Beispiel #2
0
 /// <summary>Returns the hash code for this instance.</summary>
 /// <returns>A 32-bit signed integer hash code.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ BeforeAction.GetHashCode();
         hashCode = (hashCode * 397) ^ (ItemId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)EventType;
         return(hashCode);
     }
 }
Beispiel #3
0
        public void FirePreActions(AbstractCommand command)
        {
            try
            {
                if (ShouldPingBefore)
                {
                    IO.Http.Get(PingBeforeUrl);
                }
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Ping to {PingBeforeUrl} failed before running command.", exception);
            }

            try
            {
                BeforeAction?.Invoke(command);
            }
            catch (Exception exception)
            {
                throw new LifecycleActionFailedException($"Failed to invoke action after command ran successfully.", exception);
            }
        }
Beispiel #4
0
 /// <summary>
 ///     Called before the action method is invoked.
 /// </summary>
 /// <param name="context">The action executing context.</param>
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     base.OnActionExecuting(context);
     BeforeAction?.Invoke();
 }