Exemple #1
0
        /// <summary>
        /// Gets all the action infos from a controller info.
        /// </summary>
        /// <param name="controllerInfo">The controller info.</param>
        /// <param name="kind">The controller kind.</param>
        private static void GetActionInfos(ControllerInfo controllerInfo, ControllerKind kind)
        {
            var actions = controllerInfo.ControllerType.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);

            foreach (var action in actions)
            {
                var customAttributes = action.GetCustomAttributes(false);
                //Ignore if controller is marked with [SkipJavascriptGeneration]
                if (customAttributes.OfType <SkipJavascriptGenerationAttribute>().Any())
                {
                    continue;
                }

                //MVC Controller actions aren't generated by default.
                if (kind == ControllerKind.Mvc && !customAttributes.OfType <GenerateJavascriptAttribute>().Any())
                {
                    continue;
                }

                ActionInfo.GetHttpVerb(action);
                controllerInfo.Actions.Add(new ActionInfo
                {
                    Name                = action.Name,
                    MethodInfo          = action,
                    Controller          = controllerInfo,
                    Verb                = ActionInfo.GetHttpVerb(action),
                    EnableClientCaching = customAttributes.OfType <EnableClientCacheAttribute>().Any() || controllerInfo.EnableClientCaching
                });
            }
        }