Пример #1
0
            /// <summary>
            /// Sets the default value for this named pattern part.
            /// </summary>
            /// <returns></returns>
            public PatternRoute Is <T>() where T : class, IController
            {
                var desc = ControllerInspectionUtil.Inspect(typeof(T));

                if (targetPartSubRule != null)
                {
                    targetPartSubRule.DefaultVal = desc.Name;
                }
                route.AddDefault(namedPatternPart, desc.Name);
                return(route);
            }
Пример #2
0
        /*----------------------------------------------------------------------------------------*/
        /// <summary>
        /// Searches the specified assembly for controllers and adds them to the controller tree.
        /// </summary>
        /// <param name="assembly">The assembly to search.</param>
        public void Inspect(Assembly assembly)
        {
            Type[] types = assembly.GetExportedTypes();

            foreach (Type type in types)
            {
                if (!type.IsPublic || type.IsAbstract || type.IsInterface || type.IsValueType)
                {
                    continue;
                }

                if (typeof(IController).IsAssignableFrom(type))
                {
                    ControllerDescriptor descriptor = ControllerInspectionUtil.Inspect(type);
                    Tree.AddController(descriptor.Area, descriptor.Name, descriptor.ControllerType);
                }
            }
        }
        /// <summary>
        /// Inspect the assembly's public types.
        /// </summary>
        public void Inspect(Assembly assembly)
        {
            var types = assembly.GetExportedTypes();

            foreach (var type in types)
            {
                if (!type.IsPublic || type.IsAbstract || type.IsInterface || type.IsValueType)
                {
                    continue;
                }

                if (typeof(IController).IsAssignableFrom(type))
                {
                    var contrDesc = ControllerInspectionUtil.Inspect(type);

                    RegisterController(contrDesc);
                }
            }
        }
Пример #4
0
        private void OnComponentModelCreated(ComponentModel model)
        {
            bool isController = typeof(Controller).IsAssignableFrom(model.Implementation);

            if (!isController && !typeof(ViewComponent).IsAssignableFrom(model.Implementation))
            {
                return;
            }

            // Ensure it's transient
            model.LifestyleType = LifestyleType.Transient;

            if (isController)
            {
                ControllerDescriptor descriptor = ControllerInspectionUtil.Inspect(model.Implementation);

                _tree.AddController(descriptor.Area, descriptor.Name, model.Name);
            }
        }
        /// <summary>
        /// Builds the <see cref="ControllerMetaDescriptor"/> for the specified controller type
        /// </summary>
        /// <param name="controllerType">Type of the controller.</param>
        /// <returns></returns>
        private ControllerMetaDescriptor InternalBuildDescriptor(Type controllerType)
        {
            if (logger.IsDebugEnabled)
            {
                logger.DebugFormat("Building controller descriptor for {0}", controllerType);
            }

            var descriptor = CreateMetaDescriptor();

            descriptor.ControllerDescriptor = ControllerInspectionUtil.Inspect(controllerType);

            CollectClassLevelAttributes(controllerType, descriptor);

            CollectActions(controllerType, descriptor);

            CollectActionLevelAttributes(descriptor);

            if (AfterProcess != null)
            {
                AfterProcess(descriptor);
            }

            return(descriptor);
        }
Пример #6
0
 protected virtual ControllerDescriptor GetDescriptor(Type controllerType)
 {
     return(ControllerInspectionUtil.Inspect(controllerType));
 }