public override IEnumerable <TemplMatchText> FindAll(DocX doc, TemplRegex rxp) { // Get both text and picture matches. Concat is possible due to the shared base type (MatchText) return(TemplMatchText.Find(rxp, Paragraphs) .Concat(TemplMatchPicture.Find(rxp, Paragraphs).Cast <TemplMatchText>()) .Concat(TemplMatchHyperlink.Find(rxp, Paragraphs).Cast <TemplMatchText>())); }
public static IEnumerable <TemplMatchTable> Find(TemplRegex rxp, IEnumerable <Table> tables, uint maxPerTable = TemplConst.MaxMatchesPerScope, uint maxPerRow = TemplConst.MaxMatchesPerScope, uint maxPerCell = TemplConst.MaxMatchesPerScope) { return(tables.SelectMany(t => Find(rxp, t, maxPerTable, maxPerRow, maxPerCell))); }
public override IEnumerable <TemplMatchTable> FindAll(DocX doc, TemplRegex rxp) { // Expecting only 1 match per row (yes really, per row) // Reverse(): If the handler inserts extra rows, we do not want to mess up the indexes of rows above this match. // Processing bottom-up avoids this issue. return(TemplMatchTable.Find(rxp, doc.Tables, maxPerRow: 1).Reverse()); }
public static IEnumerable <TemplMatchTable> Find(TemplRegex rxp, Table t, uint maxPerTable = TemplConst.MaxMatchesPerScope, uint maxPerRow = TemplConst.MaxMatchesPerScope, uint maxPerCell = TemplConst.MaxMatchesPerScope) { return(Enumerable.Range(0, t.RowCount).SelectMany(rowIdx => Find(rxp, t, rowIdx, maxPerRow, maxPerCell)).Take((int)maxPerTable)); }
public static IEnumerable <TemplMatchSection> Find(TemplRegex rxp, Section sec) { return(Find <TemplMatchSection>(rxp, sec.SectionParagraphs).Select(m => { m.Section = sec; return m; })); }
public static IEnumerable<TemplMatchSection> Find(TemplRegex rxp, Section sec) { return Find<TemplMatchSection>(rxp, sec.SectionParagraphs).Select(m => { m.Section = sec; return m; }); }
/// <summary> /// Find matches in a string, based on a Regex placeholder pattern. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rgx"></param> /// <param name="s"></param> public static IEnumerable <T> Find <T>(TemplRegex rgx, string s) where T : TemplMatch, new() { return(rgx.Pattern.Matches(s).Cast <Match>().Where(m => m.Success).Select(m => new T() { Regex = rgx, Body = m.Groups[1].Value, })); }
private static IEnumerable <TemplMatchHyperlink> Find(TemplRegex rxp, Paragraph p, Hyperlink hl) { return(Find <TemplMatchHyperlink>(rxp, UrlString(hl)).Select(m => { m.Hyperlink = hl; m.Paragraph = p; return m; })); }
private static IEnumerable <TemplMatchPicture> Find(TemplRegex rxp, Paragraph p, Picture pic) { return(Find <TemplMatchPicture>(rxp, pic.Description).Select(m => { m.Picture = pic; m.Width = pic.Width; m.Paragraph = p; return m; })); }
public static IEnumerable <TemplMatchTable> Find(TemplRegex rxp, Table t, int rowIdx, int cellIdx, uint maxPerCell = TemplConst.MaxMatchesPerScope) { return(Find <TemplMatchTable>(rxp, t.Rows[rowIdx].Cells[cellIdx].Paragraphs).Select(m => { m.Table = t; m.RowIndex = rowIdx; m.CellIndex = cellIdx; return m; }).Take((int)maxPerCell)); }
/// <summary> /// Find matches in a paragraph, based on a Regex placeholder pattern. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rgx"></param> /// <param name="p"></param> public static IEnumerable <T> Find <T>(TemplRegex rgx, Paragraph p) where T : TemplMatchPara, new() { var P = p; var t = P.Text; return(Find <T>(rgx, p.Text).Select(m => { m.Paragraph = p; return m; })); }
public static IEnumerable <TemplMatchHyperlink> Find(TemplRegex rxp, IEnumerable <Paragraph> paragraphs) { return(paragraphs.SelectMany(p => Find(rxp, p))); }
public static IEnumerable<TemplMatchSection> Find(TemplRegex rxp, IEnumerable<Section> sections, uint maxPerSection = TemplConst.MaxMatchesPerScope) { return sections.SelectMany(sec => Find(rxp, sec).Take((int)maxPerSection)); }
public static IEnumerable<TemplMatchText> Find(TemplRegex rxp, Paragraph p) { return Find<TemplMatchText>(rxp, p); }
public static IEnumerable <TemplMatchSection> Find(TemplRegex rxp, IEnumerable <Section> sections, uint maxPerSection = TemplConst.MaxMatchesPerScope) { return(sections.SelectMany(sec => Find(rxp, sec).Take((int)maxPerSection))); }
public static new IEnumerable <TemplMatchPicture> Find(TemplRegex rxp, Paragraph p) { return(p.Pictures .Where(pic => pic.Description != null) .SelectMany(pic => Find(rxp, p, pic))); }
public override IEnumerable <TemplMatchTable> FindAll(DocX doc, TemplRegex rxp) { // Expecting only 1 match per table return(TemplMatchTable.Find(rxp, doc.Tables, maxPerTable: 1)); }
public static IEnumerable <TemplMatchText> Find(TemplRegex rxp, IEnumerable <Paragraph> paragraphs, uint maxPerParagraph = TemplConst.MaxMatchesPerScope) { return(paragraphs.SelectMany(p => Find(rxp, p).Take((int)maxPerParagraph))); }
public override IEnumerable <TemplMatchText> FindAll(DocX doc, TemplRegex rxp) { return(TemplMatchText.Find(rxp, TemplDoc.Paragraphs(doc))); }
public static new IEnumerable<TemplMatchPicture> Find(TemplRegex rxp, Paragraph p) { return p.Pictures .Where( pic => pic.Description != null) .SelectMany(pic => Find(rxp, p, pic)); }
public static IEnumerable<TemplMatchString> Find(TemplRegex rxp, string s) { return Find<TemplMatchString>(rxp, s); }
public static IEnumerable<TemplMatchTable> Find(TemplRegex rxp, Table t, int rowIdx, int cellIdx, uint maxPerCell = TemplConst.MaxMatchesPerScope) { return Find<TemplMatchTable>(rxp, t.Rows[rowIdx].Cells[cellIdx].Paragraphs).Select(m => { m.Table = t; m.RowIndex = rowIdx; m.CellIndex = cellIdx; return m; }).Take((int)maxPerCell); }
public static IEnumerable<TemplMatchTable> Find(TemplRegex rxp, Table t, int rowIdx, uint maxPerRow = TemplConst.MaxMatchesPerScope, uint maxPerCell = TemplConst.MaxMatchesPerScope) { return Enumerable.Range(0,t.Rows[rowIdx].Cells.Count).SelectMany(cellIdx => Find(rxp, t, rowIdx, cellIdx, maxPerCell)).Take((int)maxPerRow); }
public static IEnumerable<TemplMatchTable> Find(TemplRegex rxp, IEnumerable<Table> tables, uint maxPerTable = TemplConst.MaxMatchesPerScope, uint maxPerRow = TemplConst.MaxMatchesPerScope, uint maxPerCell = TemplConst.MaxMatchesPerScope) { return tables.SelectMany(t => Find(rxp, t, maxPerTable, maxPerRow, maxPerCell)); }
public static new IEnumerable <TemplMatchHyperlink> Find(TemplRegex rxp, Paragraph p) { return(p.Hyperlinks .Where(hl => UrlString(hl).Length > 0) .SelectMany(hl => Find(rxp, p, hl))); }
/// <summary> /// Find matches in paragraphs, based on a Regex placeholder pattern. Limit n per paragraph /// </summary> /// <typeparam name="T"></typeparam> /// <param name="rgx"></param> /// <param name="paragraphs"></param> /// <param name="n"></param> public static IEnumerable <T> Find <T>(TemplRegex rgx, IEnumerable <Paragraph> paragraphs, int n) where T : TemplMatchPara, new() { return(paragraphs.SelectMany(p => Find <T>(rgx, p).Take(n))); }
public static IEnumerable <TemplMatchString> Find(TemplRegex rxp, string s) { return(Find <TemplMatchString>(rxp, s)); }
public static IEnumerable<TemplMatchHyperlink> Find(TemplRegex rxp, IEnumerable<Paragraph> paragraphs) { return paragraphs.SelectMany(p => Find(rxp, p)); }
public override IEnumerable <TemplMatchSection> FindAll(DocX doc, TemplRegex rxp) { // Expecting only 1 match per section return(TemplMatchSection.Find(rxp, doc.GetSections(), 1)); }
public static new IEnumerable<TemplMatchHyperlink> Find(TemplRegex rxp, Paragraph p) { return p.Hyperlinks .Where( hl => UrlString(hl).Length > 0) .SelectMany(hl => Find(rxp, p, hl)); }
public override IEnumerable <TemplMatchTable> FindAll(DocX doc, TemplRegex rxp) { return(TemplMatchTable.Find(rxp, doc.Tables)); }
private static IEnumerable<TemplMatchHyperlink> Find(TemplRegex rxp, Paragraph p, Hyperlink hl) { return Find<TemplMatchHyperlink>(rxp, UrlString(hl)).Select(m => { m.Hyperlink= hl; m.Paragraph = p; return m; }); }
public override IEnumerable <TemplMatchText> FindAll(DocX doc, TemplRegex rxp) { // Expecting only 1 match per paragraph return(TemplMatchText.Find(rxp, TemplDoc.Paragraphs(doc), 1)); }
public static IEnumerable <TemplMatchText> Find(TemplRegex rxp, Paragraph p) { return(Find <TemplMatchText>(rxp, p)); }
private static IEnumerable<TemplMatchPicture> Find(TemplRegex rxp, Paragraph p, Picture pic) { return Find<TemplMatchPicture>(rxp, pic.Description).Select(m => { m.Picture = pic; m.Width = pic.Width; m.Paragraph = p; return m; }); }
public static IEnumerable<TemplMatchText> Find(TemplRegex rxp, IEnumerable<Paragraph> paragraphs, uint maxPerParagraph = TemplConst.MaxMatchesPerScope) { return paragraphs.SelectMany(p => Find(rxp, p).Take((int)maxPerParagraph)); }