/// <summary> /// Gets the set of <see cref="IWebHookFilterProvider"/> 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 <IWebHookFilterProvider> GetFilterProviders(this IDependencyScope services) { IEnumerable <IWebHookFilterProvider> filterProviders = services.GetServices <IWebHookFilterProvider>(); if (filterProviders == null || !filterProviders.Any()) { filterProviders = CustomApiServices.GetFilterProviders(); } return(filterProviders); }
/// <summary> /// Gets the set of <see cref="IWebHookRegistrar"/> 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 <IWebHookRegistrar> GetRegistrars(this IDependencyScope services) { IEnumerable <IWebHookRegistrar> registrar = services.GetServices <IWebHookRegistrar>(); if (registrar == null || !registrar.Any()) { registrar = CustomApiServices.GetRegistrars(); } return(registrar); }
public void Configuration(IAppBuilder app) { GlobalConfiguration.Configure(config => { config.Filters.Add(new MyAuthorizeAttribute()); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); config.DependencyResolver = new MyResolver(); CustomApiServices.SetIdValidator(new MyWebHookIdValidator()); config.InitializeCustomWebHooks(); config.InitializeCustomWebHooksAzureStorage(false); //config.InitializeCustomWebHooksAzureQueueSender(); config.InitializeCustomWebHooksApis(); }); }
public DependencyScopeExtensionsTests() { _resolverMock = new Mock <IDependencyScope>(); _config = new HttpConfiguration(); CustomApiServices.Reset(); }
/// <summary> /// Gets an <see cref="IWebHookIdValidator"/> implementation registered with the Dependency Injection engine /// or a default implementation if none are registered. /// </summary> /// <param name="services">The <see cref="IDependencyScope"/> implementation.</param> /// <returns>The registered <see cref="IWebHookIdValidator"/> instance or a default implementation if none are registered.</returns> public static IWebHookIdValidator GetIdValidator(this IDependencyScope services) { IWebHookIdValidator validator = services.GetService <IWebHookIdValidator>(); return(validator ?? CustomApiServices.GetIdValidator()); }