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)); }
internal static string ControllerName(this ApiDescription apiDescription) { var controllerActionDescriptor = apiDescription.ControllerActionDescriptor(); return((controllerActionDescriptor == null) ? null : controllerActionDescriptor.ControllerName); }