Exemplo n.º 1
0
        public void ParseNextRow(IFileReader reader, RowData rowData)
        {
            ArgumentVerifier.CheckObjectArgument(reader, "reader");

            if (rowData != null)
            {
                rowData.ResetRowData();
            }
            this.fieldParser.ResetParsingState();

            if (this.singleColumn)
            {
                fieldParser.ParseNext(reader, rowData);
                if (rowData != null)
                {
                    string columnData = fieldParser.CurrentText;
                    if (!reader.IsEOF || !string.IsNullOrEmpty(columnData))
                    {
                        rowData.AddColumnData(fieldParser.CurrentText);
                    }
                }
            }
            else
            {
                while (!reader.IsEOF && !this.fieldParser.RowDelimiterMatch)
                {
                    this.fieldParser.ParseNext(reader, rowData);

                    if (rowData != null)
                    {
                        string columnData = fieldParser.CurrentText;
                        if (!reader.IsEOF || rowData.ColumnCount > 0 || !string.IsNullOrEmpty(columnData))
                        {
                            if (MaxColumnNumber == rowData.ColumnCount)
                            {
                                throw new RowColumnNumberOverflow();
                            }
                            // Add data if this is not the last and empty row.
                            rowData.AddColumnData(fieldParser.CurrentText);
                        }
                    }
                }
            }
        }
        public void ParseNextRow(IFileReader reader, RowData rowData)
        {
            ArgumentVerifier.CheckObjectArgument(reader, "reader");

            if (rowData != null)
            {
                rowData.ResetRowData();
            }
            this.fieldParser.ResetParsingState();

            if (this.singleColumn)
            {
                fieldParser.ParseNext(reader, rowData);
                if (rowData != null)
                {
                    string columnData = fieldParser.CurrentText;
                    if (!reader.IsEOF || !string.IsNullOrEmpty(columnData))
                    {
                        rowData.AddColumnData(fieldParser.CurrentText);
                    }
                }
            }
            else
            {
                while (!reader.IsEOF && !this.fieldParser.RowDelimiterMatch)
                {
                    this.fieldParser.ParseNext(reader, rowData);

                    if (rowData != null)
                    {
                        string columnData = fieldParser.CurrentText;
                        if (!reader.IsEOF || rowData.ColumnCount > 0 || !string.IsNullOrEmpty(columnData))
                        {
                            if (MaxColumnNumber == rowData.ColumnCount)
                            {
                                throw new RowColumnNumberOverflow();
                            }
                            // Add data if this is not the last and empty row.
                            rowData.AddColumnData(fieldParser.CurrentText);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void ResetRowDataTest()
 {
     RowData target = new RowData();
     target.AddColumnData("A");
     target.AddColumnData("B");
     Assert.AreEqual<int>(2, target.ColumnCount);
     target.ResetRowData();
     Assert.AreEqual<int>(0, target.ColumnCount);
 }
Exemplo n.º 4
0
 public void AddColumnDataTest()
 {
     RowData target = new RowData();
     target.AddColumnData("ABC");
     Assert.AreEqual<int>(1, target.ColumnCount);
     target.AddColumnData("DEF");
     Assert.AreEqual<int>(2, target.ColumnCount);
     Assert.AreEqual<string>("ABC", target.GetColumnData(0));
     Assert.AreEqual<string>("DEF", target.GetColumnData(1));
 }
Exemplo n.º 5
0
        private RowData GenerateRowData(string [] columnData)
        {
            RowData rowData = new RowData();
            foreach (string columnValue in columnData)
            {
                rowData.AddColumnData(columnValue);
            }

            return rowData;
        }