Exemple #1
0
        public static Func <T, R> AsThrottledDebounce <T, R>(this Func <T, R> self, double delayInMs, bool skipFirstEvent = false)
        {
            EventHandler <EventHandlerResult <R> > action          = (input, output) => { output.result = self((T)input); };
            EventHandler <EventHandlerResult <R> > throttledAction = action.AsThrottledDebounce(delayInMs, skipFirstEvent);

            return((T input) => {
                var output = new EventHandlerResult <R>();
                throttledAction(input, output);
                return output.result;
            });
        }
        public async Task Handle <T>(T eventArgs) where T : EventArgs
        {
            using IServiceScope scope = _provider.CreateScope();

            foreach (Type reactionHandlerType in _eventHandlers)
            {
                if (!reactionHandlerType.IsAssignableTo(typeof(IEventHandler <T>)))
                {
                    continue;
                }

                IEventHandler <T> handler =
                    scope.ServiceProvider.GetService(reactionHandlerType) as IEventHandler <T>
                    ?? throw new ArgumentOutOfRangeException();
                EventHandlerResult shouldStop =
                    await handler.Handle(eventArgs).ConfigureAwait(false);

                if (shouldStop == EventHandlerResult.Stop)
                {
                    return;
                }
            }
        }
Exemple #3
0
 protected override Task <EventHandlerResult> executeCore(Octokit.ActivityPayload webhookPayload)
 {
     return(Task.FromResult(EventHandlerResult.ActionPerformed("TestHandler ok")));
 }
 public async Task <EventHandlerResult> Execute(string requestBody)
 {
     return(EventHandlerResult.ActionPerformed("Test"));
 }