Exemplo n.º 1
0
        public void Read(TextReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            using (var xsvReader = new XsvReader(reader, Settings.CommentToken))
            {
                var headers = ReadHeader(xsvReader);
                _columnHeaders = new XsvColumnHeaders(headers);
                var rows = xsvReader.ReadXsvToEnd(Settings.Delimiters);

                _items.Clear();
                foreach (var row in rows)
                {
                    _items.Add(CreateXsvRow(headers, row));
                }
            }
        }
Exemplo n.º 2
0
        public async Task ReadAsync(TextReader reader, CancellationToken cancellationToken)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            if (cancellationToken == null)
            {
                throw new ArgumentNullException("cancellationToken");
            }

            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            using (var xsvReader = new XsvReader(reader, Settings.CommentToken))
            {
                var headers = await ReadHeaderAsync(xsvReader);

                _columnHeaders = new XsvColumnHeaders(headers);

                _items.Clear();
                while (!xsvReader.EndOfData)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }

                    var row = await xsvReader.ReadXsvLineAsync(Settings.Delimiters);

                    _items.Add(CreateXsvRow(headers, row));
                }
            }
        }
Exemplo n.º 3
0
 public void SetColumnHeaders(IEnumerable <string> source)
 {
     _columnHeaders = new XsvColumnHeaders(source);
 }