Example #1
0
 /// <summary>
 /// Registers every necessary services for the controllers
 /// </summary>
 /// <param name="harpoon"></param>
 /// <returns></returns>
 public static IHarpoonBuilder AddControllersWithDefaultValidator <TWebHookTriggerProvider>(this IHarpoonBuilder harpoon)
     where TWebHookTriggerProvider : class, IWebHookTriggerProvider
 {
     harpoon.Services.TryAddSingleton <IWebHookTriggerProvider, TWebHookTriggerProvider>();
     harpoon.UseDefaultValidator();
     return(harpoon);
 }
        /// <summary>
        /// Registers <see cref="WebHookStore{TContext}"/> as <see cref="IWebHookStore"/> and <see cref="WebHookRegistrationStore{TContext}"/> as <see cref="IWebHookRegistrationStore"/>.
        /// TWebHookTriggerProvider needs to be configured.
        /// </summary>
        /// <typeparam name="TContext"></typeparam>
        /// <param name="harpoon"></param>
        /// <param name="validatorPolicy"></param>
        /// <returns></returns>
        public static IHarpoonBuilder RegisterWebHooksUsingEfStorage <TContext>(this IHarpoonBuilder harpoon, Action <IHttpClientBuilder> validatorPolicy)
            where TContext : DbContext, IRegistrationsContext
        {
            harpoon.Services.TryAddScoped <IPrincipalIdGetter, DefaultPrincipalIdGetter>();
            harpoon.Services.TryAddSingleton <IWebHookMatcher, DefaultWebHookMatcher>();
            harpoon.Services.TryAddScoped <IWebHookStore, WebHookStore <TContext> >();
            harpoon.Services.TryAddScoped <IWebHookRegistrationStore, WebHookRegistrationStore <TContext> >();

            harpoon.UseDefaultValidator(validatorPolicy);

            return(harpoon);
        }
 /// <summary>
 /// Registers services to use the default <see cref="IWebHookValidator"/> implementation. Necessary to use default controllers.
 /// </summary>
 /// <param name="harpoon"></param>
 /// <returns></returns>
 public static IHarpoonBuilder UseDefaultValidator(this IHarpoonBuilder harpoon) => harpoon.UseDefaultValidator(b => { });