Exemplo n.º 1
0
        /// <summary>
        /// Gets the record.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the record.</param>
        /// <returns>The record.</returns>
        public virtual object GetRecord(Type type)
        {
            CheckDisposed();
            CheckHasBeenRead();

            return(GetReadRecordFunc(type)(this));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets all the records in the CSV file and
        /// converts each to <see cref="Type"/> T. The Read method
        /// should not be used when using this.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the record.</param>
        /// <returns>An <see cref="IList{Object}" /> of records.</returns>
        public virtual IEnumerable <object> GetRecords(Type type)
        {
            CheckDisposed();

            // Don't need to check if it's been read
            // since we're doing the reading ourselves.

            while (Read())
            {
                object record;
                try
                {
                    record = GetReadRecordFunc(type)(this);
                }
                catch (CsvReaderException)
                {
                    // We threw the exception, so let it go.
                    throw;
                }
                catch (Exception ex)
                {
                    throw ExceptionHelper.GetReaderException <CsvReaderException>("An error occurred reading the record.", ex, parser, type, namedIndexes, currentIndex, currentRecord);
                }
                yield return(record);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets all the records in the CSV file and
        /// converts each to <see cref="Type"/> T. The Read method
        /// should not be used when using this.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the record.</param>
        /// <returns>An <see cref="IList{Object}" /> of records.</returns>
        public virtual IEnumerable <object> GetRecords(Type type)
        {
            CheckDisposed();
            // Don't need to check if it's been read
            // since we're doing the reading ourselves.

            while (Read())
            {
                object record;
                try
                {
                    record = GetReadRecordFunc(type)(this);
                }
                catch (CsvReaderException)
                {
                    // We threw the exception, so let it go.
                    throw;
                }
                catch (Exception ex)
                {
                    throw new CsvReaderException(GetExceptionMessage(type, ex), ex);
                }
                yield return(record);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the record converted into <see cref="Type"/> T.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the record.</typeparam>
        /// <returns>The record converted to <see cref="Type"/> T.</returns>
        public virtual T GetRecord <T>() where T : class
        {
            CheckDisposed();
            CheckHasBeenRead();

            return(GetReadRecordFunc <T>()(this));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets all the records in the CSV file and
        /// converts each to <see cref="Type"/> T. The Read method
        /// should not be used when using this.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the record.</typeparam>
        /// <returns>An <see cref="IList{T}" /> of records.</returns>
        public virtual IEnumerable <T> GetRecords <T>() where T : class
        {
            CheckDisposed();

            while (Read())
            {
                yield return(GetReadRecordFunc <T>()(this));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets all the records in the CSV file and
        /// converts each to <see cref="Type"/> T. The Read method
        /// should not be used when using this.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the record.</param>
        /// <returns>An <see cref="IList{Object}" /> of records.</returns>
        public virtual IEnumerable <object> GetRecords(Type type)
        {
            CheckDisposed();
            // Don't need to check if it's been read
            // since we're doing the reading ourselves.

            while (Read())
            {
                yield return(GetReadRecordFunc(type)(this));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets all the records in the CSV file and
        /// converts each to <see cref="Type"/> T. The Read method
        /// should not be used when using this.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the record.</typeparam>
        /// <returns>An <see cref="IList{T}" /> of records.</returns>
        public virtual IEnumerable <T> GetRecords <T>() where T : class
        {
            CheckDisposed();
            // Don't need to check if it's been read
            // since we're doing the reading ourselves.

            while (Read())
            {
                yield return(GetReadRecordFunc <T>()(this));
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the record converted into <see cref="Type"/> T.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the record.</typeparam>
        /// <returns>The record converted to <see cref="Type"/> T.</returns>
        public virtual T GetRecord <T>() where T : class
        {
            CheckDisposed();
            CheckHasBeenRead();

            T record;

            try
            {
                record = GetReadRecordFunc <T>()();
            }
            catch (Exception ex)
            {
                ExceptionHelper.AddExceptionDataMessage(ex, parser, typeof(T), namedIndexes, currentIndex, currentRecord);
                throw;
            }
            return(record);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the record.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the record.</param>
        /// <returns>The record.</returns>
        public virtual object GetRecord(Type type)
        {
            CheckDisposed();
            CheckHasBeenRead();

            object record;

            try
            {
                record = GetReadRecordFunc(type)(this);
            }
            catch (CsvReaderException)
            {
                // We threw the exception, so let it go.
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionHelper.GetReaderException <CsvReaderException>("An error occurred reading the record.", ex, parser, type, namedIndexes, currentIndex, currentRecord);
            }
            return(record);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the record converted into <see cref="Type"/> T.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the record.</typeparam>
        /// <returns>The record converted to <see cref="Type"/> T.</returns>
        public virtual T GetRecord <T>() where T : class
        {
            CheckDisposed();
            CheckHasBeenRead();

            T record;

            try
            {
                record = GetReadRecordFunc <T>()(this);
            }
            catch (CsvReaderException)
            {
                // We threw the exception, so let it go.
                throw;
            }
            catch (Exception ex)
            {
                throw ExceptionHelper.GetReaderException <CsvReaderException>("An error occurred reading the record.", ex, parser, typeof(T), namedIndexes, currentIndex, currentRecord);
            }
            return(record);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets all the records in the CSV file and
        /// converts each to <see cref="Type"/> T. The Read method
        /// should not be used when using this.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the record.</typeparam>
        /// <returns>An <see cref="IList{T}" /> of records.</returns>
        public virtual IEnumerable <T> GetRecords <T>() where T : class
        {
            CheckDisposed();
            // Don't need to check if it's been read
            // since we're doing the reading ourselves.

            while (Read())
            {
                T record;
                try
                {
                    record = GetReadRecordFunc <T>()();
                }
                catch (Exception ex)
                {
                    ExceptionHelper.AddExceptionDataMessage(ex, parser, typeof(T), namedIndexes, currentIndex, currentRecord);
                    throw;
                }

                yield return(record);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the record.
        /// </summary>
        /// <param name="type">The <see cref="Type"/> of the record.</param>
        /// <returns>The record.</returns>
        public virtual object GetRecord(Type type)
        {
            CheckDisposed();
            CheckHasBeenRead();

            object record;

            try
            {
                record = GetReadRecordFunc(type)(this);
            }
            catch (CsvReaderException)
            {
                // We threw the exception, so let it go.
                throw;
            }
            catch (Exception ex)
            {
                throw new CsvReaderException(GetExceptionMessage(type, ex), ex);
            }
            return(record);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the record converted into <see cref="Type"/> T.
        /// </summary>
        /// <typeparam name="T">The <see cref="Type"/> of the record.</typeparam>
        /// <returns>The record converted to <see cref="Type"/> T.</returns>
        public virtual T GetRecord <T>() where T : class
        {
            CheckDisposed();
            CheckHasBeenRead();

            T record;

            try
            {
                record = GetReadRecordFunc <T>()(this);
            }
            catch (CsvReaderException)
            {
                // We threw the exception, so let it go.
                throw;
            }
            catch (Exception ex)
            {
                throw new CsvReaderException(GetExceptionMessage(typeof(T), ex), ex);
            }
            return(record);
        }