void RegisterHandlerMethod(HandlerMethod handlerMethod)
        {
            var eventType = handlerMethod.Method.GetParameters().First().ParameterType;

            _registry.RegisterHandlerMethod(eventType, handlerMethod);
            _logger.Information($"GitHubWebHookHandlers - Registered {handlerMethod.Type.FullName} for handling event {eventType.Name}");
        }
        /// <inheritdoc/>
        public void Perform()
        {
            _logger.Information($"GitHubWebHookHandlers - Discovering handlers");

            foreach (var handler in _handlers)
            {
                var handlerMethods = HandlerMethod.GetUsableHandlerMethodsFrom(handler);

                if (!handlerMethods.Any())
                {
                    continue;
                }

                _logger.Information($"GitHubWebHookHandlers - Type {handler.FullName} can handle webhooks");

                handlerMethods.ForEach(_ => RegisterHandlerMethod(_));
            }
        }
Beispiel #3
0
 /// <summary>
 /// Instantiates a new instance of a <see cref="Webhook" />
 /// </summary>
 /// <param name="handler">The handler and method to execute</param>
 /// <param name="payload">The payload of the webhook to execute</param>
 public Webhook(HandlerMethod handler, ActivityPayload payload)
 {
     Handler = handler;
     Payload = payload;
 }
Beispiel #4
0
 ConcurrentBag <HandlerMethod> AppendToExisting(ConcurrentBag <HandlerMethod> list, HandlerMethod toAdd)
 {
     list.Add(toAdd);
     return(list);
 }
Beispiel #5
0
 /// <inheritdoc />
 public void RegisterHandlerMethod(Type payloadType, HandlerMethod handlerMethod)
 {
     _registeredHandlers.AddOrUpdate(payloadType, new ConcurrentBag <HandlerMethod> {
         handlerMethod
     }, (key, list) => AppendToExisting(list, handlerMethod));
 }