public static FortifyPathElement Parse(XmlReader xmlReader, FortifyStrings strings)
{
//<xs:complexType name="PathElement">
// <xs:sequence>
// <xs:element name="FileName" type="xs:string" minOccurs="1" maxOccurs="1"/>
// <xs:element name="FilePath" type="xs:string" minOccurs="1" maxOccurs="1"/>
// <xs:element name="LineStart" type="xs:string" minOccurs="1" maxOccurs="1"/>
// <xs:element name="Snippet" type="xs:string" minOccurs="0" maxOccurs="1"/>
// <xs:element name="SnippetLine" type="xs:int" minOccurs="0" maxOccurs="1"/>
// <xs:element name="TargetFunction" type="xs:string" minOccurs="0" maxOccurs="1"/>
// </xs:sequence>
//</xs:complexType>
if (xmlReader.NodeType != XmlNodeType.Element || xmlReader.IsEmptyElement)
{
throw xmlReader.CreateException(ConverterResources.FortifyNotValidPathElement);
}
xmlReader.Read(); // Always true because !IsEmptyElement
xmlReader.IgnoreElement(strings.FileName, IgnoreOptions.Required);
string filePath = xmlReader.ReadElementContentAsString(strings.FilePath, String.Empty);
int lineStart = xmlReader.ReadElementContentAsInt(strings.LineStart, String.Empty);
xmlReader.IgnoreElement(strings.Snippet, IgnoreOptions.Optional);
xmlReader.IgnoreElement(strings.SnippetLine, IgnoreOptions.Optional);
string targetFunction = xmlReader.ReadOptionalElementContentAsString(strings.TargetFunction);
xmlReader.ReadEndElement();
try
{
return new FortifyPathElement(filePath, lineStart, targetFunction);
}
catch (ArgumentException ex)
{
throw xmlReader.CreateException(ex.Message);
}
}