public Histogram(Func <int, TBucket> IndexToBucket) { this.IndexToBucket = IndexToBucket; Data = new Table <HistogramRow <TBucket>, TColumn, double>(); indexer = Data.Indexer( row => row.SortedContinous(z => Row(z.Index + 1)), column => column.AutoCreate()); }
public void Constructor_NoTableGrid_ThrowsException() { SafeExecuteTest( StandardDocPath, (doc) => { var expected = doc.MainDocumentPart.Document.Body.Descendants<Table>().FirstOrDefault(); expected.RemoveAllChildren<TableGrid>(); // renders the table invalid. var indexer = new TableIndexer(expected); // boom }); }
public void ImplicitCast_ValidIndexer_SameReference() { SafeExecuteTest( StandardDocPath, (doc) => { var expected = doc.MainDocumentPart.Document.Body.Descendants<Table>().FirstOrDefault(); var indexer = new TableIndexer(expected); var target = (Table)indexer; // Check references Assert.AreSame(expected, target); }); }
public void Constructor_FourRowThreeColumnTable_ValidIndexer() { SafeExecuteTest( FourRowsThreeColumnsDocPath, (doc) => { var expected = doc.MainDocumentPart.Document.Body.Descendants<Table>().FirstOrDefault(); var indexer = new TableIndexer(expected); Assert.IsNotNull(indexer.Table); Assert.AreEqual(indexer.Columns.Count(), 3); Assert.AreEqual(indexer.Rows.Count(), 4); }); }
public BodyIndexer(Body toIndex) { if (toIndex == null) { throw new ArgumentNullException("toIndex"); } this.Body = toIndex; this.paragraphs = new List<ParagraphIndexer>(); this.tables = new List<TableIndexer>(); // This is uglier than Linq, but way more efficient. For large documents, we only // wish to go throught the entire list fo elements ONCE, not multiple times. foreach (var element in toIndex.Elements()) { if (element != null) { if (element is Paragraph) { var indexer = new ParagraphIndexer(element as Paragraph); this.paragraphs.Add(indexer); } else if (element is Table) { var indexer = new TableIndexer(element as Table); this.tables.Add(indexer); } else if (element is SectionProperties) { this.FinalSectionProperties = element as SectionProperties; } } } // This element should always exist. this.FinalSectionProperties = toIndex.Elements<SectionProperties>().FirstOrDefault(); }
public void Constructor_NullArgument_ThrowsException() { var target = new TableIndexer(null); }