/// <summary> /// Exports the violations found within this document into the given xml node. /// </summary> /// <param name="document">The document containing the violations.</param> /// <param name="violationsDocument">The xml document in which to store the violation information.</param> /// <param name="parentNode">The parent node within this xml document under which to store the violation information.</param> internal static void ExportViolations(ICodeDocument document, XmlDocument violationsDocument, XmlNode parentNode) { Param.AssertNotNull(document, "document"); Param.AssertNotNull(violationsDocument, "violationsDocument"); Param.AssertNotNull(parentNode, "parentNode"); if (document.DocumentContents != null) { SourceParser.ExportElementViolations(document.DocumentContents, violationsDocument, parentNode); } if (document.SourceCode != null) { // Add the violations from the source code. foreach (Violation violation in document.SourceCode.Violations) { SourceParser.ExportViolation(violation, violationsDocument, parentNode); } } }
/// <summary> /// Exports the violations found within this document into the given xml node. /// </summary> /// <param name="element">The element containing the violations to export.</param> /// <param name="violationsDocument">The xml document in which to store the violation information.</param> /// <param name="parentNode">The parent node within this xml document under which to store the violation information.</param> private static void ExportElementViolations(ICodeElement element, XmlDocument violationsDocument, XmlNode parentNode) { Param.AssertNotNull(element, "element"); Param.AssertNotNull(violationsDocument, "violationsDocument"); Param.AssertNotNull(parentNode, "parentNode"); // Add the violations from this element. foreach (Violation violation in element.Violations) { SourceParser.ExportViolation(violation, violationsDocument, parentNode); } // Add this violations from this element's children. IEnumerable <ICodeElement> children = element.ChildCodeElements; if (children != null) { foreach (ICodeElement child in children) { SourceParser.ExportElementViolations(child, violationsDocument, parentNode); } } }