Exemple #1
0
        private static bool MatchesActionArguments(this TRoute route, ICollection <Type> actionArguments)
        {
            if (actionArguments == null)
            {
                return(true);
            }

            // When specifying arguments, it must be an action level attribute route with a single action descriptor
            TActionDescriptor actionDescriptor = ((TActionDescriptor[])route.DataTokens[RouteDataTokenKeys.Actions]).Single();

            ICollection <TParameterDescriptor> parameterInfos = actionDescriptor.GetParameters();

            if (parameterInfos.Count() != actionArguments.Count)
            {
                return(false);
            }

            for (int i = 0; i < actionArguments.Count; i++)
            {
                if (actionArguments.ElementAt(i) != parameterInfos.ElementAt(i).ParameterType)
                {
                    return(false);
                }
            }

            return(true);
        }
        static docMember GetMethodDocComment(DocCommentLookup lookup, System.Web.Http.Controllers.HttpActionDescriptor descriptor)
        {
            var methodFullName = descriptor.ControllerDescriptor.ControllerType.FullName + "." + descriptor.ActionName;
            var parameters     = descriptor.GetParameters();

            if (parameters.Count > 0)
            {
                methodFullName += "(" + parameters.Select(d => d.ParameterType.FullName).Aggregate((c, n) => c + "," + n) + ")";
            }

            return(lookup.GetMember("M:" + methodFullName));
        }