Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 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
         });
 }
Exemplo n.º 3
0
        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);
               });
        }
Exemplo n.º 4
0
        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);
               });
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
 public void Constructor_NullArgument_ThrowsException()
 {
     var target = new TableIndexer(null);
 }