Пример #1
0
        public CsvColumn(CsvHeader header, CsvField field, int index)
        {
            if (header is null || field is null)
            {
                throw new ArgumentNullException();
            }

            Header = header;
            Field  = field;
            Index  = index;
        }
Пример #2
0
        public CsvFormat(IEnumerable <CsvColumn> columns)
        {
            if (columns is null)
            {
                throw new ArgumentNullException();
            }
            if (!columns.Any())
            {
                throw new ArgumentException();
            }

            CsvColumn[] sortedColumns = columns.OrderBy(column => column.Index).ToArray();
            int         columnCount   = sortedColumns.Length;

            Fields  = new CsvField[columnCount];
            Headers = new CsvHeader[columnCount];

            for (var i = 0; i < columnCount; i++)
            {
                Fields[i]  = sortedColumns[i].Field;
                Headers[i] = sortedColumns[i].Header;
            }
        }