private void CorrectForCellIndex(Row row)
 {
     while (reader.MoveToNextAttribute())
     {
         if (IsIndexAttribute())
         {
             row.AddEmptyCells(GetMissingCount(row.CellCount));
         }
     }
 }
 private static bool IsDivider(Row row)
 {
     return row.IsEmpty();
 }
 private static bool IsComment(Row row)
 {
     List<Cell> cells = row.Cells;
     return cells.Count > 0 && !cells[0].IsEmpty();
 }
Example #4
0
 private static void AssertDataRowFilled(Row dataRow, int length)
 {
     Assert.AreEqual(length, dataRow.CellCount);
     dataRow.Cells.ForEach(cell => Assert.IsFalse(string.IsNullOrEmpty(cell.Value)));
 }
Example #5
0
 private void AssertCorrectDataLength(Row dataRow, int headerCellCount)
 {
     int dataCellCount = dataRow.CellCount;
     if (dataCellCount != headerCellCount)
     {
         throw new MalformedTestException(
             string.Format("Cannot initialize test - mismatch in number of headers and data values. [headers {0}, cells {1}]. Title: {2}", headerCellCount, dataCellCount, Title));
     }
 }
 private static bool IsComment(Row currentRow)
 {
     if (currentRow.Cells.Count == 0) return false;
     string value = currentRow.Cells[0].Value;
     return value != null && value.StartsWith("*");
 }
            private void ReadRowCells(Row row)
            {
                while (true)
                {
                    reader.MoveToNextElement();

                    if (reader.IsStartElement("Cell"))
                    {
                        ReadCell(row);
                    }

                    if (reader.IsEndElement("Row"))
                    {
                        return;
                    }
                }
            }
            void ReadRow(Table table)
            {
                reader.AssertIsStartElement("Row");

                bool isEmptyRow = reader.IsEmptyElement;
                if (isEmptyRow)
                {
                    table.AddEmptyRow();
                }

                CorrectForRowIndex(table);

                if (! isEmptyRow)
                {
                    var row = new Row();
                    table.AddRow(row);
                    ReadRowCells(row);
                }
            }
            private void ReadCellData(Row row)
            {
                bool dataRead = false;
                while (true)
                {
                    reader.MoveToNextElement();
                    if (reader.IsStartElement("Data"))
                    {
                        if (dataRead) throw new ApplicationException("Multiple Data elements within a Cell element");

                        row.AddCell(new Cell(ReadData()));
                        dataRead = true;
                    }

                    if (reader.IsEndElement("Cell"))
                    {
                        if (!dataRead) row.AddEmptyCell();
                        return;
                    }
                }
            }
            void ReadCell(Row row)
            {
                reader.AssertIsStartElement("Cell");

                bool isEmptyCell = reader.IsEmptyElement;
                if (isEmptyCell)
                    row.AddEmptyCell();

                CorrectForCellIndex(row);

                if (!isEmptyCell)
                    ReadCellData(row);
            }
Example #11
0
 public void AddRow(Row row)
 {
     Rows.Add(row);
 }