本文整理汇总了C#中XmlReader.CreateException方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.CreateException方法的具体用法?C# XmlReader.CreateException怎么用?C# XmlReader.CreateException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.CreateException方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessCppCheckLog
private void ProcessCppCheckLog(XmlReader reader, IResultLogWriter output)
{
reader.ReadStartElement(_strings.Results);
if (!Ref.Equal(reader.LocalName, _strings.CppCheck))
{
throw reader.CreateException(ConverterResources.CppCheckCppCheckElementMissing);
}
string version = reader.GetAttribute(_strings.Version);
if (version != null && !version.IsSemanticVersioningCompatible())
{
// This logic only fixes up simple cases, such as being passed
// 1.66, where Semantic Versioning 2.0 requires 1.66.0. Also
// strips Revision member if passed a complete .NET version.
Version dotNetVersion;
if (Version.TryParse(version, out dotNetVersion))
{
version =
Math.Max(0, dotNetVersion.Major) + "." +
Math.Max(0, dotNetVersion.Minor) + "." +
Math.Max(0, dotNetVersion.Build);
}
}
if (String.IsNullOrWhiteSpace(version))
{
throw reader.CreateException(ConverterResources.CppCheckCppCheckElementMissing);
}
reader.Skip(); // <cppcheck />
if (!Ref.Equal(reader.LocalName, _strings.Errors))
{
throw reader.CreateException(ConverterResources.CppCheckErrorsElementMissing);
}
var results = new List<Result>();
if (reader.IsEmptyElement)
{
reader.Skip(); // <errors />
}
else
{
int errorsDepth = reader.Depth;
reader.Read(); // <errors>
while (reader.Depth > errorsDepth)
{
var parsedError = CppCheckError.Parse(reader, _strings);
results.Add(parsedError.ToSarifIssue());
}
reader.ReadEndElement(); // </errors>
}
reader.ReadEndElement(); // </results>
var tool = new Tool
{
Name = "CppCheck",
Version = version,
};
var fileInfoFactory = new FileInfoFactory(uri => MimeType.Cpp);
Dictionary<string, FileData> fileDictionary = fileInfoFactory.Create(results);
output.Initialize(id: null, correlationId: null);
output.WriteTool(tool);
if (fileDictionary != null && fileDictionary.Count > 0) { output.WriteFiles(fileDictionary); }
output.OpenResults();
output.WriteResults(results);
output.CloseResults();
}