Beispiel #1
0
        public TaggedTable Process()
        {
            TaggedTable table    = new TaggedTable();
            int         rowIndex = 0;

            foreach (var line in _LineSplit())
            {
                rowIndex++;
                var cells = line.Split(';');
                Row row   = table.NewRow();
                for (int i = 0; i < cells.Length; i++)
                {
                    var cell = cells[i];

                    List <Tag> tags     = new List <Tag>();
                    List <int> ends     = new List <int>();
                    int        startTag = -1;
                    for (int _ = 0; _ < 100; _++)
                    {
                        startTag = cell.IndexOf('<', startTag + 1);
                        if (startTag == -1)
                        {
                            break;
                        }
                        var endTag = cell.IndexOf('>', startTag);
                        if (endTag == -1)
                        {
                            break;
                        }
                        tags.Add(TagFactory.Parse(cell.Substring(startTag, endTag - startTag + 1), rowIndex, i + 1, startTag));
                        ends.Add(endTag);
                    }

                    List <string> builder = new List <String>();

                    if (tags.Any())
                    {
                        int oldJ = 0;
                        builder.Add(cell.Substring(0, tags[0].start));
                        for (int j = 1; j < tags.Count; j++)
                        {
                            builder.Add(cell.Substring(ends[oldJ] + 1, tags[j].start - ends[oldJ] - 1));
                            oldJ = j;
                        }

                        if (ends.Last() < cell.Length)
                        {
                            builder.Add(cell.Substring(ends[oldJ] + 1));
                        }

                        row.Add(string.Join("", builder));

                        table.Tags.AddRange(tags);
                    }
                    else
                    {
                        row.Add(cell);
                    }
                }
            }
            return(table);
        }
Beispiel #2
0
 public TableProcess(TaggedTable table)
 {
     _Table = table;
 }