예제 #1
0
        public static IEnumerable <object> ActionAttributes(this ApiDescription apiDescription)
        {
            var controllerActionDescriptor = apiDescription.ControllerActionDescriptor();

            return((controllerActionDescriptor == null)
                ? Enumerable.Empty <object>()
                : controllerActionDescriptor.MethodInfo.GetCustomAttributes(false));
        }
        /// <summary>
        /// Retrieves all attributes of the controller and it's parents
        /// </summary>
        /// <param name="apiDescription"></param>
        /// <returns></returns>
        public static IEnumerable <object> AllControllerAttributes(this ApiDescription apiDescription)
        {
            var controllerActionDescriptor = apiDescription.ControllerActionDescriptor();

            if (controllerActionDescriptor == null)
            {
                return(Enumerable.Empty <object>());
            }

            // Using controllerActionDescriptor.type.GetCustomTypes(true) returns invalid attribute collection,
            // so we need to manually traverse the hierarchy tree
            return(GetHierarchyControllerAttributes(controllerActionDescriptor.ControllerTypeInfo));
        }
예제 #3
0
        internal static string ControllerName(this ApiDescription apiDescription)
        {
            var controllerActionDescriptor = apiDescription.ControllerActionDescriptor();

            return((controllerActionDescriptor == null) ? null : controllerActionDescriptor.ControllerName);
        }