Exemplo n.º 1
0
        /// <summary>
        /// Opens a table from the specified stream with the specified header loader.
        /// </summary>
        /// <param name="stream">The stream of dBASE table to open. The stream is closed when the returned table instance is disposed.</param>
        /// <param name="headerLoader">The header loader.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
        /// <returns>A table instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c> or <paramref name="headerLoader"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="stream"/> does not allow reading.</exception>
        /// <exception cref="NotSupportedException">The dBASE table contains one or more columns of unsupported type.</exception>
        public static async Task <Table> OpenAsync(Stream stream, HeaderLoader headerLoader, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (!stream.CanRead)
            {
                throw new ArgumentException($"The stream does not allow reading ({nameof(stream.CanRead)} property returns false).", nameof(stream));
            }
            if (headerLoader == null)
            {
                throw new ArgumentNullException(nameof(headerLoader));
            }

            Header header = await headerLoader.LoadAsync(stream, cancellationToken).ConfigureAwait(false);

            return(new Table(header, stream));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens a table from the specified stream with the specified header loader.
        /// </summary>
        /// <param name="stream">The stream of dBASE table to open. The stream is closed when the returned table instance is disposed.</param>
        /// <param name="headerLoader">The header loader.</param>
        /// <returns>A table instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c> or <paramref name="headerLoader"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="stream"/> does not allow reading.</exception>
        public static Table Open(Stream stream, HeaderLoader headerLoader)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (!stream.CanRead)
            {
                throw new ArgumentException($"The stream does not allow reading ({nameof(stream.CanRead)} property returns false).", nameof(stream));
            }
            if (headerLoader == null)
            {
                throw new ArgumentNullException(nameof(headerLoader));
            }

            Header header = headerLoader.Load(stream);

            return(new Table(header, stream));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Opens a table from the specified stream with the specified header loader.
        /// </summary>
        /// <param name="stream">The stream of dBASE table to open. The stream is closed when the returned table instance is disposed.</param>
        /// <param name="headerLoader">The header loader.</param>
        /// <returns>A table instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c> or <paramref name="headerLoader"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="stream"/> does not allow reading.</exception>
        /// <exception cref="NotSupportedException">The dBASE table constains one or more columns of unsupported type.</exception>
        public static async Task<Table> OpenAsync(Stream stream, HeaderLoader headerLoader)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (!stream.CanRead)
            {
                throw new ArgumentException($"The stream does not allow reading ({nameof(stream.CanRead)} property returns false).", nameof(stream));
            }
            if (headerLoader == null)
            {
                throw new ArgumentNullException(nameof(headerLoader));
            }

            Header header = await headerLoader.LoadAsync(stream).ConfigureAwait(false);
            return new Table(header, stream);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Opens a table from the specified stream with the specified header loader.
        /// </summary>
        /// <param name="stream">The stream of dBASE table to open. The stream is closed when the returned table instance is disposed.</param>
        /// <param name="headerLoader">The header loader.</param>
        /// <returns>A table instance.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="stream"/> is <c>null</c> or <paramref name="headerLoader"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="stream"/> does not allow reading.</exception>
        /// <exception cref="NotSupportedException">The dBASE table constains one or more columns of unsupported type.</exception>
        public static Table Open(Stream stream, HeaderLoader headerLoader)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (!stream.CanRead)
            {
                throw new ArgumentException($"The stream does not allow reading ({nameof(stream.CanRead)} property returns false).", nameof(stream));
            }
            if (headerLoader == null)
            {
                throw new ArgumentNullException(nameof(headerLoader));
            }

            Header header = headerLoader.Load(stream);
            return new Table(header, stream);
        }