Esempio n. 1
0
        /// <summary>Replaces all filter providers in services with <see cref="DryIocFilterProvider"/>, and registers it in container.</summary>
        /// <param name="container">DryIoc container.</param> <param name="services">Services</param>
        public static void SetFilterProvider(this IContainer container, ServicesContainer services)
        {
            var providers = services.GetFilterProviders();

            services.RemoveAll(typeof(IFilterProvider), _ => true);
            container.RegisterInstance <IFilterProvider>(new DryIocFilterProvider(container, providers), IfAlreadyRegistered.Replace);
        }
Esempio n. 2
0
        /// <summary>Replaces all filter providers in services with <see cref="DryIocFilterProvider"/>, and registers it in container.</summary>
        /// <param name="container">DryIoc container.</param> <param name="services">Services</param>
        public static void SetFilterProvider(this IContainer container, ServicesContainer services)
        {
            var providers = services.GetFilterProviders();

            services.RemoveAll(typeof(IFilterProvider), _ => true);
            var filterProvider = new DryIocFilterProvider(container, providers);

            container.UseInstance <IFilterProvider>(filterProvider);
        }
Esempio n. 3
0
        /// <summary>
        ///     Installs Filter provider with injectable property dependencies support.
        /// </summary>
        /// <param name="services">Services container, <see cref="ServicesContainer" /></param>
        /// <param name="container">Windsor container, <see cref="IWindsorContainer" /> </param>
        /// <param name="propertyDescriptorCache">Injectable property cache</param>
        /// <returns>Windsor container</returns>
        public static void InstallHttpFilterProvider([NotNull] this ServicesContainer services,
                                                     [NotNull] IWindsorContainer container, ITypePropertyDescriptorCache propertyDescriptorCache)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var providers = services.GetFilterProviders().Where(i => i is ActionDescriptorFilterProvider).ToArray();

            foreach (var filterProvider in providers)
            {
                services.Remove(typeof(IFilterProvider), filterProvider);
            }

            services.Add(typeof(IFilterProvider), new WindsorHttpFilterProvider(container, propertyDescriptorCache));
        }