Provides singleton instances of WebHook receiver services. If alternative implementations are provided by a Dependency Injection engine then those instances are used instead.
Beispiel #1
0
        /// <summary>
        /// Gets the set of <see cref="IWebHookReceiver"/> instances registered with the Dependency Injection engine
        /// or an empty collection if none are registered.
        /// </summary>
        /// <param name="services">The <see cref="IDependencyScope"/> implementation.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> containing the registered instances.</returns>
        public static IEnumerable <IWebHookReceiver> GetReceivers(this IDependencyScope services)
        {
            IEnumerable <IWebHookReceiver> receivers = services.GetServices <IWebHookReceiver>();

            if (receivers == null || !receivers.Any())
            {
                receivers = ReceiverServices.GetReceivers();
            }
            return(receivers);
        }
Beispiel #2
0
        /// <summary>
        /// Gets an <see cref="IWebHookHandlerSorter"/> implementation registered with the Dependency Injection engine
        /// or a default implementation if none is registered.
        /// </summary>
        /// <param name="services">The <see cref="IDependencyScope"/> implementation.</param>
        /// <returns>The registered <see cref="IWebHookReceiverManager"/> instance or a default implementation if none are registered.</returns>
        public static IWebHookHandlerSorter GetHandlerSorter(this IDependencyScope services)
        {
            IWebHookHandlerSorter handlerSorter = services.GetService <IWebHookHandlerSorter>();

            if (handlerSorter == null)
            {
                handlerSorter = ReceiverServices.GetHandlerSorter();
            }
            return(handlerSorter);
        }
Beispiel #3
0
        /// <summary>
        /// Gets an <see cref="IWebHookReceiverConfig"/> implementation registered with the Dependency Injection engine
        /// or a default implementation if none is registered.
        /// </summary>
        /// <param name="services">The <see cref="IDependencyScope"/> implementation.</param>
        /// <returns>The registered <see cref="IWebHookReceiverManager"/> instance or a default implementation if none are registered.</returns>
        public static IWebHookReceiverConfig GetReceiverConfig(this IDependencyScope services)
        {
            IWebHookReceiverConfig receiverConfig = services.GetService <IWebHookReceiverConfig>();

            if (receiverConfig == null)
            {
                SettingsDictionary settings = services.GetSettings();
                ILogger            logger   = services.GetLogger();
                receiverConfig = ReceiverServices.GetReceiverConfig(settings, logger);
            }
            return(receiverConfig);
        }
Beispiel #4
0
        /// <summary>
        /// Gets an <see cref="IWebHookReceiverManager"/> implementation registered with the Dependency Injection engine
        /// or a default implementation if none is registered.
        /// </summary>
        /// <param name="services">The <see cref="IDependencyScope"/> implementation.</param>
        /// <returns>The registered <see cref="IWebHookReceiverManager"/> instance or a default implementation if none are registered.</returns>
        public static IWebHookReceiverManager GetReceiverManager(this IDependencyScope services)
        {
            IWebHookReceiverManager receiverManager = services.GetService <IWebHookReceiverManager>();

            if (receiverManager == null)
            {
                IEnumerable <IWebHookReceiver> receivers = services.GetReceivers();
                ILogger logger = services.GetLogger();
                receiverManager = ReceiverServices.GetReceiverManager(receivers, logger);
            }
            return(receiverManager);
        }
Beispiel #5
0
        /// <summary>
        /// Gets the set of <see cref="IWebHookHandler"/> instances registered with the Dependency Injection engine
        /// or an empty collection if none are registered.
        /// </summary>
        /// <param name="services">The <see cref="IDependencyScope"/> implementation.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> containing the registered instances.</returns>
        public static IEnumerable <IWebHookHandler> GetHandlers(this IDependencyScope services)
        {
            IEnumerable <IWebHookHandler> handlers = services.GetServices <IWebHookHandler>();

            if (handlers == null || !handlers.Any())
            {
                handlers = ReceiverServices.GetHandlers();
            }

            // Sort handlers
            IWebHookHandlerSorter sorter = services.GetHandlerSorter();

            return(sorter.SortHandlers(handlers));
        }