本文整理汇总了C#中Scanner.Scan方法的典型用法代码示例。如果您正苦于以下问题:C# Scanner.Scan方法的具体用法?C# Scanner.Scan怎么用?C# Scanner.Scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.Scan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanParseSimpleFilename2
public void CanParseSimpleFilename2()
{
var scanner = new Scanner("*.txt");
AssertToken(TokenKind.Wildcard, "*", scanner.Scan());
AssertToken(TokenKind.Identifier, ".txt", scanner.Scan());
AssertToken(TokenKind.EOT, "", scanner.Scan());
}
示例2: ParseWindowsRoot
public void ParseWindowsRoot()
{
var scanner = new Scanner(@"C:\*.txt");
AssertToken(TokenKind.WindowsRoot, "C:", scanner.Scan());
AssertToken(TokenKind.PathSeperator, "\\", scanner.Scan());
AssertToken(TokenKind.Wildcard, "*", scanner.Scan());
AssertToken(TokenKind.Identifier, ".txt", scanner.Scan());
AssertToken(TokenKind.EOT, "", scanner.Scan());
}
示例3: Scan_Should_Return_Empty_When_Regex_Match_Is_Greater_Than_Zero
public void Scan_Should_Return_Empty_When_Regex_Match_Is_Greater_Than_Zero()
{
var scanner = new Scanner("a b c");
var match = scanner.Scan("b");
Assert.Equal(match, "");
Assert.Equal(scanner.Pos, 0);
}
示例4: Scan_Should_Return_Empty_When_Regex_Does_Not_Match
public void Scan_Should_Return_Empty_When_Regex_Does_Not_Match()
{
var scanner = new Scanner("a b c");
var match = scanner.Scan("z");
Assert.Equal(match, "");
Assert.Equal(scanner.Pos, 0);
}
示例5: Scan
public static ScanResult Scan(string expression)
{
var scanner = new Scanner();
scanner.text = expression;
scanner.Scan();
return scanner.result;
}
示例6: It_Should_Match_Whole_String
public void It_Should_Match_Whole_String()
{
var scanner = new Scanner("a b c");
var match = scanner.Scan("a b c");
Assert.Equal(match, scanner.Template);
Assert.True(scanner.EOS);
}
示例7: Scan_Should_Match_When_Regex_Starts_At_Zero
public void Scan_Should_Match_When_Regex_Starts_At_Zero()
{
var scanner = new Scanner("a b c");
var match = scanner.Scan("a");
Assert.Equal(match, "a");
Assert.Equal(scanner.Pos, 1);
}
示例8: It_scans_literal_text
public void It_scans_literal_text()
{
var scanner = new Scanner();
var parts = scanner.Scan("foo");
parts.IsEqualTo(new LiteralText("foo"));
}
示例9: It_returns_no_parts_for_the_empty_string
public void It_returns_no_parts_for_the_empty_string()
{
var scanner = new Scanner();
var parts = scanner.Scan("");
parts.IsEmpty();
}
示例10: It_skips_comments
public void It_skips_comments()
{
var scanner = new Scanner();
var parts = scanner.Scan("before{{!foo}}after");
parts.IsEqualTo(new LiteralText("before"),
new LiteralText("after"));
}
示例11: It_scans_template_definitions
public void It_scans_template_definitions()
{
var scanner = new Scanner();
var parts = scanner.Scan("{{<foo}}inside{{/foo}}");
parts.IsEqualTo(new TemplateDefinition("foo"),
new LiteralText("inside"),
new EndSection("foo"));
}
示例12: Scan_NotStarted_ReturnsFalse
public void Scan_NotStarted_ReturnsFalse()
{
var httpClientHelper = A.Fake<IHttpClientHelper>();
var scanner = new Scanner(A.Fake<ISettings>(), A.Fake<ILogger>(), httpClientHelper);
A.CallTo(() => httpClientHelper.MakeHttpRequest(A<string>.Ignored, A<HttpResponseType>.Ignored)).Returns("{\"status\":\"0\"}");
bool hasStarted = scanner.Scan("");
Assert.AreEqual(false, hasStarted);
}
示例13: It_scans_variable_references
public void It_scans_variable_references()
{
var scanner = new Scanner();
var parts = scanner.Scan("before{{foo}}after");
parts.IsEqualTo(new LiteralText("before"),
new VariableReference("foo"),
new LiteralText("after"));
}
示例14: Scan_Finished_ReturnsTrue
public void Scan_Finished_ReturnsTrue()
{
var httpClientHelper = A.Fake<IHttpClientHelper>();
var scanner = new Scanner(A.Fake<ISettings>(), A.Fake<ILogger>(), httpClientHelper);
A.CallTo(() => httpClientHelper.MakeHttpRequest(A<string>.Ignored, HttpResponseType.json)).Returns("{\"code\":\"scan_in_progress\"}");
bool hasStarted = scanner.Scan("");
Assert.AreEqual(true, hasStarted);
}
示例15: It_scans_sections
public void It_scans_sections()
{
var scanner = new Scanner();
var parts = scanner.Scan("{{#foo}}inside{{/foo}}");
parts.IsEqualTo(new Block("foo"),
new LiteralText("inside"),
new EndSection("foo"));
}