示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TypeCatalogBuilder"/> class.
        /// </summary>
        /// <param name="typeCatalog">The type catalog.</param>
        public TypeCatalogBuilder([NotNull] TypeCatalog typeCatalog)
        {
            Invariant.IsNotNull(typeCatalog, "typeCatalog");

            TypeCatalog = typeCatalog;
        }
        /// <summary>
        /// Registers the specified instance.
        /// </summary>
        /// <typeparam name="TControllerActivator">The type of the action invoker.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="typeCatalog">The type catalog.</param>
        /// <returns></returns>
        public static TypeMappingRegistry <Controller, IControllerActivator> Register <TControllerActivator>(this TypeMappingRegistry <Controller, IControllerActivator> instance, TypeCatalog typeCatalog) where TControllerActivator : IControllerActivator
        {
            Invariant.IsNotNull(instance, "instance");
            Invariant.IsNotNull(typeCatalog, "typeCatalog");

            IList <Type> controllerTypes = typeCatalog.ToList();

            EnsureControllerTypes(controllerTypes);

            Type controllerActivatorType = typeof(TControllerActivator);

            foreach (Type controllerType in controllerTypes)
            {
                instance.Register(controllerType, controllerActivatorType);
            }

            return(instance);
        }
示例#3
0
        /// <summary>
        /// Registers the specified filters for the given controller types.
        /// </summary>
        /// <typeparam name="TFilter1">The type of the filter1.</typeparam>
        /// <typeparam name="TFilter2">The type of the filter2.</typeparam>
        /// <typeparam name="TFilter3">The type of the filter3.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="typeCatalog">The controller types.</param>
        /// <returns></returns>
        public static IFilterRegistry Register <TFilter1, TFilter2, TFilter3>(this IFilterRegistry instance, TypeCatalog typeCatalog)
            where TFilter1 : IMvcFilter
            where TFilter2 : IMvcFilter
            where TFilter3 : IMvcFilter
        {
            Invariant.IsNotNull(instance, "instance");
            Invariant.IsNotNull(typeCatalog, "typeCatalog");

            return(Register(instance, typeCatalog, typeof(TFilter1), typeof(TFilter2), typeof(TFilter3)));
        }
示例#4
0
        /// <summary>
        /// Registers and configures the specified filter for the given controller types.
        /// </summary>
        /// <typeparam name="TFilter">The type of the filter.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="typeCatalog">The controller types.</param>
        /// <param name="configureFilter">The configure filter action.</param>
        /// <returns></returns>
        public static IFilterRegistry Register <TFilter>(this IFilterRegistry instance, TypeCatalog typeCatalog, Action <TFilter> configureFilter)
            where TFilter : IMvcFilter
        {
            Invariant.IsNotNull(instance, "instance");
            Invariant.IsNotNull(typeCatalog, "typeCatalog");
            Invariant.IsNotNull(configureFilter, "configureFilter");

            IList <Type> controllerTypeList = typeCatalog.ToList();

            EnsureControllerTypes(controllerTypeList);

            foreach (Type itemType in controllerTypeList.Select(controllerType => genericControllerItemType.MakeGenericType(controllerType)))
            {
                instance.Items.Add(Activator.CreateInstance(itemType, new object[] { CreateAndConfigureFilterFactory(instance, configureFilter) }) as FilterRegistryItem);
            }

            return(instance);
        }
示例#5
0
 /// <summary>
 /// Registers the specified filter for the given controller types.
 /// </summary>
 /// <typeparam name="TFilter">The type of the filter.</typeparam>
 /// <param name="instance">The instance.</param>
 /// <param name="typeCatalog">The controller types.</param>
 /// <returns></returns>
 public static IFilterRegistry Register <TFilter>(this IFilterRegistry instance, TypeCatalog typeCatalog)
     where TFilter : IMvcFilter
 {
     return(Register <TFilter>(instance, typeCatalog, filter => { }));
 }
        /// <summary>
        /// Registers the specified instance.
        /// </summary>
        /// <typeparam name="TModelBinder">The type of the action invoker.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <param name="typeCatalog">The type catalog.</param>
        /// <returns></returns>
        public static TypeMappingRegistry <object, IModelBinder> Register <TModelBinder>(this TypeMappingRegistry <object, IModelBinder> instance, TypeCatalog typeCatalog) where TModelBinder : IModelBinder
        {
            Invariant.IsNotNull(instance, "instance");
            Invariant.IsNotNull(typeCatalog, "typeCatalog");

            Type modelBinderType = typeof(TModelBinder);

            foreach (Type modelType in typeCatalog.ToList())
            {
                instance.Register(modelType, modelBinderType);
            }

            return(instance);
        }
        public static TypeMappingRegistry <IView, IViewPageActivator> Register <TViewPageActivator>([NotNull] this TypeMappingRegistry <IView, IViewPageActivator> instance, [NotNull] TypeCatalog typeCatalog)
        {
            Invariant.IsNotNull(instance, "instance");
            Invariant.IsNotNull(typeCatalog, "typeCatalog");

            IList <Type> viewTypes = typeCatalog.ToList();

            EnsureViewTypes(viewTypes);

            Type viewPageActivatorType = typeof(TViewPageActivator);

            foreach (Type viewType in viewTypes)
            {
                instance.Register(viewType, viewPageActivatorType);
            }

            return(instance);
        }