示例#1
0
            public FindReplaceResult(IDocument doc, IEnumerable <ISearchResult> results, Func <int, string> nameGetter)
            {
                var rope  = new ICSharpCode.AvalonEdit.Utils.Rope <char>();
                var table = new DataTable();

                table.BeginLoadData();

                if (!results.Any())
                {
                    return;
                }

                var regexResult = results.First() as SearchResult;

                if (regexResult == null)
                {
                    table.Columns.Add("$0", typeof(string));
                }
                else
                {
                    var i = 0;
                    foreach (var group in regexResult.Data.Groups.OfType <Group>())
                    {
                        table.Columns.Add(nameGetter(i), typeof(string));
                        i++;
                    }
                }

                foreach (var result in results)
                {
                    rope.AddRange(doc.GetText(result) + Environment.NewLine);

                    regexResult = result as SearchResult;
                    if (regexResult == null)
                    {
                        table.Rows.Add(doc.GetText(result));
                    }
                    else
                    {
                        table.Rows.Add(regexResult.Data.Groups.OfType <Group>().Select(g => g.Value).ToArray());
                    }
                }

                table.EndLoadData();
                _set = new DataSet();
                _set.Tables.Add(table);
                _text = new RopeTextSource(rope);
            }
示例#2
0
      public FindReplaceResult(IDocument doc, IEnumerable<ISearchResult> results, Func<int, string> nameGetter)
      {
        var rope = new ICSharpCode.AvalonEdit.Utils.Rope<char>();
        var table = new DataTable();
        table.BeginLoadData();

        if (!results.Any())
          return;

        var regexResult = results.First() as SearchResult;
        if (regexResult == null)
        {
          table.Columns.Add("$0", typeof(string));
        }
        else
        {
          var i = 0;
          foreach (var group in regexResult.Data.Groups.OfType<Group>())
          {
            table.Columns.Add(nameGetter(i), typeof(string));
            i++;
          }
        }

        foreach (var result in results)
        {
          rope.AddRange(doc.GetText(result) + Environment.NewLine);

          regexResult = result as SearchResult;
          if (regexResult == null)
          {
            table.Rows.Add(doc.GetText(result));
          }
          else
          {
            table.Rows.Add(regexResult.Data.Groups.OfType<Group>().Select(g => g.Value).ToArray());
          }
        }

        table.EndLoadData();
        _set = new DataSet();
        _set.Tables.Add(table);
        _text = new RopeTextSource(rope);
      }