Inheritance: IOperationFilter
Beispiel #1
0
 private static void ApplyParamComments(
     Operation operation,
     XPathNavigator methodNode,
     MethodInfo method)
 {
     if (operation.parameters == null)
     {
         return;
     }
     foreach (Parameter parameter1 in (IEnumerable <Parameter>)operation.parameters)
     {
         Parameter     parameter     = parameter1;
         ParameterInfo parameterInfo = ((IEnumerable <ParameterInfo>)method.GetParameters()).FirstOrDefault <ParameterInfo>((Func <ParameterInfo, bool>)(paramInfo =>
         {
             if (!ApplyXmlActionComments.HasBoundName(paramInfo, parameter.name))
             {
                 return(paramInfo.Name == parameter.name);
             }
             return(true);
         }));
         if (parameterInfo != null)
         {
             XPathNavigator node = methodNode.SelectSingleNode(string.Format("param[@name='{0}']", (object)parameterInfo.Name));
             if (node != null)
             {
                 parameter.description = node.ExtractContent();
             }
         }
     }
 }
Beispiel #2
0
        public void Apply(
            Operation operation,
            SchemaRegistry schemaRegistry,
            ApiDescription apiDescription)
        {
            ReflectedHttpActionDescriptor actionDescriptor = apiDescription.get_ActionDescriptor() as ReflectedHttpActionDescriptor;

            if (actionDescriptor == null)
            {
                return;
            }
            XPathNavigator navigator;

            lock (this._xmlDoc)
                navigator = this._xmlDoc.CreateNavigator();
            string         commentIdForMethod = XmlCommentsIdHelper.GetCommentIdForMethod(actionDescriptor.get_MethodInfo());
            XPathNavigator methodNode         = navigator.SelectSingleNode(string.Format("/doc/members/member[@name='{0}']", (object)commentIdForMethod));

            if (methodNode == null)
            {
                return;
            }
            XPathNavigator node1 = methodNode.SelectSingleNode("summary");

            if (node1 != null)
            {
                operation.summary = node1.ExtractContent();
            }
            XPathNavigator node2 = methodNode.SelectSingleNode("remarks");

            if (node2 != null)
            {
                operation.description = node2.ExtractContent();
            }
            ApplyXmlActionComments.ApplyParamComments(operation, methodNode, actionDescriptor.get_MethodInfo());
            ApplyXmlActionComments.ApplyResponseComments(operation, methodNode);
        }