本文整理汇总了C#中SourceCode.Read方法的典型用法代码示例。如果您正苦于以下问题:C# SourceCode.Read方法的具体用法?C# SourceCode.Read怎么用?C# SourceCode.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceCode
的用法示例。
在下文中一共展示了SourceCode.Read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseFile
public override bool ParseFile(SourceCode sourceCode, int passNumber, ref CodeDocument document)
{
Param.RequireNotNull(sourceCode, "sourceCode");
Param.RequireGreaterThanOrEqualToZero(passNumber, "passNumber");
Param.Ignore(document);
StyleCopTrace.In(sourceCode, passNumber, document);
// The document is parsed on the first pass. On any subsequent passes, we do not do anything.
if (passNumber == 0)
{
if (this.SkipAnalysisForDocument(sourceCode))
{
return false;
}
try
{
using (TextReader reader = sourceCode.Read())
{
// Create the document.
if (reader == null)
{
this.AddViolation(sourceCode, 1, Rules.FileMustBeReadable);
}
else
{
// Create the lexer object for the code string.
CodeLexer lexer = new CodeLexer(this, sourceCode, new CodeReader(reader));
// Parse the document.
CodeParser parser = new CodeParser(this, lexer);
parser.ParseDocument();
document = parser.Document;
}
}
}
catch (SyntaxException syntaxex)
{
this.AddViolation(syntaxex.SourceCode, syntaxex.LineNumber, Rules.SyntaxException, syntaxex.Message);
CsDocument csdocument = new CsDocument(sourceCode, this);
csdocument.FileHeader = new FileHeader(string.Empty, new CsTokenList(csdocument.Tokens), new Reference<ICodePart>(csdocument));
document = csdocument;
}
}
return StyleCopTrace.Out(false);
}