Exemplo n.º 1
0
        public TokenizeResult Tokenize(Template template, string input)
        {
            var result = new TokenizeResult(template);

            Tokenize(result, null, template, input);

            return(result);
        }
Exemplo n.º 2
0
        public TokenizeResult <T> Tokenize <T>(Template template, string input) where T : class, new()
        {
            var result = new TokenizeResult <T>(template);

            Tokenize(result, result.Value, template, input);

            return(result);
        }
Exemplo n.º 3
0
        public static void Write(TokenizeResult result)
        {
            sb.Clear();

            var listNames = new List <string>();

            foreach (var match in result.Matches)
            {
                var name = match.Token.Name;

                if (result.Matches.Count(m => m.Token.Name == name) > 1)
                {
                    if (listNames.Contains(name))
                    {
                        continue;
                    }

                    var listMatches = result.All(name);
                    var listCount   = 0;

                    sb.AppendLine();
                    WriteValue($@"result.All(""{name}"").Count", listMatches.Count);
                    foreach (var listMatch in listMatches)
                    {
                        WriteValue($@"result.All(""{name}"")[{listCount}]", listMatch);

                        listCount++;
                    }
                    sb.AppendLine();

                    listNames.Add(name);
                }
                else
                {
                    WriteValue($@"result.First(""{name}"")", match.Value);
                }
            }

            Console.Write(sb.ToString());
            WindowsClipboard.SetText(sb.ToString());
        }