예제 #1
0
        public static void Remove <TProvider>(this FilterProviderCollection providers) where TProvider : IFilterProvider
        {
            var provider = FilterProviders.Providers.FirstOrDefault(f => f is TProvider);

            if (null != provider)
            {
                providers.Remove(provider);
            }
        }
        /// <summary>
        /// Replace the default filter attribute filter provider with an instance
        /// of this type.
        /// </summary>
        /// <param name="filterProviders">The global filter provider collection.</param>
        public static void Install(FilterProviderCollection filterProviders)
        {
            if (filterProviders == null) throw new ArgumentNullException("filterProviders");

            var existing = filterProviders.OfType<FilterAttributeFilterProvider>().SingleOrDefault();
            if (existing != null)
                filterProviders.Remove(existing);
            filterProviders.Add(new ImportCapableFilterAttributeFilterProvider());
        }
예제 #3
0
        public static void RegisterFilterProviders(FilterProviderCollection providers)
        {
            // Remove the old provider since we do not want dubplicates
            providers.Remove <FilterAttributeFilterProvider>();

            // Create the IKernel and register the services
            var kernel = new StandardKernel();

            kernel.Bind <IMessageService>().To <MessageService>();

            // Register the provider with the MVC3 runtime
            providers.Add(new InjectableFilterProvider(kernel));
        }
        public static IWindsorContainer InstallMvcFilterProvider(
            [NotNull] this FilterProviderCollection filterProviders, [NotNull] IWindsorContainer container,
            [CanBeNull] TypePropertyDescriptorCache propertyDescriptorCache)
        {
            if (filterProviders == null)
            {
                throw new ArgumentNullException(nameof(filterProviders));
            }
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }
            var attributeFilterProviders = filterProviders.OfType <FilterAttributeFilterProvider>().ToArray();

            foreach (var attributeFilterProvider in attributeFilterProviders)
            {
                filterProviders.Remove(attributeFilterProvider);
            }
            filterProviders.Add(new WindsorFilterAttributeProvider(container, propertyDescriptorCache));
            return(container);
        }
예제 #5
0
 public void RegisterFilterProviders(FilterProviderCollection providers)
 {
     providers.Remove<FilterAttributeFilterProvider>();
     providers.Add(new WindsorFilterProvider(Container));
 }
예제 #6
0
        public static void Remove <TProvider>(this FilterProviderCollection providers) where TProvider : IFilterProvider
        {
            var provider = FilterProviders.Providers.Single(f => f is TProvider);

            providers.Remove(provider);
        }