AccessProviderSample.AccessDBContentWriter.Seek C# (CSharp) Метод

Seek() публичный Метод

Moves the content reader specified number of rows from the origin
public Seek ( long offset, System origin ) : void
offset long Number of rows to offset
origin System Starting row from which to offset
Результат void
        public void Seek(long offset, System.IO.SeekOrigin origin)
        {
            // get the number of rows in the table which will help in
            // calculating current position
            string tableName;
            int rowNumber;

            PathType type = provider.GetNamesFromPath(path, out tableName, out rowNumber);

            if (type == PathType.Invalid)
            {
                throw new ArgumentException("Path specified should represent either a table or a row : " + path);
            }

            Collection<DatabaseRowInfo> rows =
                provider.GetRows(tableName);

            int numRows = rows.Count;

            if (offset > rows.Count)
            {
                throw new
                    ArgumentException(
                    "Offset cannot be greater than the number of rows available"
                    );
            }

            if (origin == System.IO.SeekOrigin.Begin)
            {
                // starting from Beginning with an index 0, the current offset
                // has to be advanced to offset - 1
                currentOffset = offset - 1;
            }
            else if (origin == System.IO.SeekOrigin.End)
            {
                // starting from the end which is numRows - 1, the current
                // offset is so much less than numRows - 1
                currentOffset = numRows - 1 - offset;
            }
            else
            {
                // calculate from the previous value of current offset
                // advancing forward always
                currentOffset += offset;
            }
        }