private static void ApplyPropertyComments(XPathNavigator navigator, Schema propertySchema, PropertyInfo propertyInfo)
        {
            if (propertyInfo == null)
            {
                return;
            }

            var commentId    = XmlCommentsIdHelper.GetCommentIdForProperty(propertyInfo);
            var propertyNode = navigator.SelectSingleNode(string.Format(MemberXPath, commentId));

            if (propertyNode == null)
            {
                return;
            }

            var propSummaryNode = propertyNode.SelectSingleNode(SummaryTag);

            if (propSummaryNode != null)
            {
                propertySchema.description = propSummaryNode.ExtractContent();
            }

            var propExampleNode = propertyNode.SelectSingleNode(ExampleTag);

            if (propExampleNode != null)
            {
                propertySchema.example = propExampleNode.ExtractContent();
            }
        }
        public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
        {
            var reflectedActionDescriptor = apiDescription.ActionDescriptor as ReflectedHttpActionDescriptor;

            if (reflectedActionDescriptor == null)
            {
                return;
            }

            XPathNavigator navigator;

            lock (_xmlDoc)
            {
                navigator = _xmlDoc.CreateNavigator();
            }

            var commentId  = XmlCommentsIdHelper.GetCommentIdForMethod(reflectedActionDescriptor.MethodInfo);
            var methodNode = navigator.SelectSingleNode(string.Format(MemberXPath, commentId));

            if (methodNode == null)
            {
                return;
            }

            var summaryNode = methodNode.SelectSingleNode(SummaryXPath);

            if (summaryNode != null)
            {
                operation.summary = summaryNode.ExtractContent();
            }

            var remarksNode = methodNode.SelectSingleNode(RemarksXPath);

            if (remarksNode != null)
            {
                operation.description = remarksNode.ExtractContent();
            }

            ApplyParamComments(operation, methodNode, reflectedActionDescriptor.MethodInfo);

            ApplyResponseComments(operation, methodNode);
        }
        public void Apply(Schema model, ModelFilterContext context)
        {
            XPathNavigator navigator;

            lock (_xmlDoc)
            {
                navigator = _xmlDoc.CreateNavigator();
            }

            var commentId = XmlCommentsIdHelper.GetCommentIdForType(context.SystemType);
            var typeNode  = navigator.SelectSingleNode(string.Format(MemberXPath, commentId));

            if (typeNode != null)
            {
                var summaryNode = typeNode.SelectSingleNode(SummaryTag);
                if (summaryNode != null)
                {
                    model.description = summaryNode.ExtractContent();
                }

                var exampleNode = typeNode.SelectSingleNode(ExampleTag);
                if (exampleNode != null)
                {
                    model.example = exampleNode.ExtractContent();
                }
            }

            if (model.properties != null)
            {
                foreach (var entry in model.properties)
                {
                    var jsonProperty = context.JsonObjectContract.Properties[entry.Key];
                    if (jsonProperty == null)
                    {
                        continue;
                    }

                    ApplyPropertyComments(navigator, entry.Value, jsonProperty.PropertyInfo());
                }
            }
        }