1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5

6
namespace TurnerSoftware.RobotsExclusionTools.Tokenization.Validators
7
{
8
	public class RobotsPageTokenPatternValidator : TokenPatternValidatorBase
9
	{
10 1
		private static readonly Dictionary<TokenType, IEnumerable<TokenPattern>> TokenPatterns = new Dictionary<TokenType, IEnumerable<TokenPattern>>
11 1
		{
12 1
			{
13 1
				TokenType.Field,
14 1
				new[]
15 1
				{
16 1
					new TokenPattern(TokenType.Field, new[]{ TokenType.NewLine }, new[] { TokenType.FieldValueDelimiter })
17 1
				}
18 1
			},
19 1
			{
20 1
				TokenType.Value,
21 1
				new[]
22 1
				{
23 1
					new TokenPattern(TokenType.Value, new[]{ TokenType.FieldValueDelimiter, TokenType.Field }, null),
24 1
					new TokenPattern(TokenType.Value, null, null)
25 1
				}
26 1
			},
27 1
			{
28 1
				TokenType.FieldValueDelimiter,
29 1
				new[]
30 1
				{
31 1
					new TokenPattern(TokenType.FieldValueDelimiter, new[] { TokenType.Field }, null)
32 1
				}
33 1
			},
34 1
			{
35 1
				TokenType.ValueDelimiter,
36 1
				new[]
37 1
				{
38 1
					new TokenPattern(TokenType.ValueDelimiter, new[] { TokenType.Value }, new[] { TokenType.Value })
39 1
				}
40 1
			}
41 1
		};
42

43
		protected override IEnumerable<TokenPattern> LookupTokenPatterns(TokenType tokenType)
44 1
		{
45 1
			if (TokenPatterns.ContainsKey(tokenType))
46 1
			{
47 1
				return TokenPatterns[tokenType];
48
			}
49

50 1
			return Enumerable.Empty<TokenPattern>();
51 1
		}
52
	}
53
}

Read our documentation on viewing source code .

Loading