Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CsvColumn"/> struct.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="columnIndex">Index of the column.</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public CsvColumn(CsvDocument document, int columnIndex)
        {
            _columnIndex = columnIndex;
            if (_columnIndex <0 | columnIndex> document.Header.Length)
            {
                throw new ArgumentOutOfRangeException($"{nameof(columnIndex)}: {columnIndex}");
            }

            _records = document._records;
            Name     = document.Header[_columnIndex];
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CsvColumn"/> struct.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="columnName">Name of the column.</param>
        /// <exception cref="ArgumentException">If cannot find the column.</exception>
        public CsvColumn(CsvDocument document, string columnName)
        {
            _columnIndex = document.Header.IndexOf(columnName);

            if (_columnIndex < 0)
            {
                throw new ArgumentException("Cannot find a column named: " + columnName);
            }

            _records = document._records;
            Name     = columnName;
        }
Beispiel #3
0
 internal Builder(CsvDocument document)
 {
     _document = document;
     _values   = new object[document.Header.Length];
     _pos      = 0;
 }