Seek() public abstract method

public abstract Seek ( long offset, SeekOrigin origin ) : long
offset long
origin SeekOrigin
return long
Beispiel #1
0
        // Read data of specified length from specified offset into a buffer

        public long Read(long offset, char[] buffer, int offsetInBuffer, int count)
        {
            if (IsNull)
            {
                throw new SqlNullValueException();
            }

            // Validate the arguments
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            if (offset > this.Length || offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset");
            }

            if (offsetInBuffer > buffer.Length || offsetInBuffer < 0)
            {
                throw new ArgumentOutOfRangeException("offsetInBuffer");
            }

            if (count < 0 || count > buffer.Length - offsetInBuffer)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            // Adjust count based on data length
            if (count > this.Length - offset)
            {
                count = (int)(this.Length - offset);
            }

            if (count != 0)
            {
                switch (_state)
                {
                case SqlBytesCharsState.Stream:
                    if (m_stream.Position != offset)
                    {
                        m_stream.Seek(offset, SeekOrigin.Begin);
                    }
                    m_stream.Read(buffer, offsetInBuffer, count);
                    break;

                default:
                    // ProjectK\Core doesn't support long-typed array indexers
                    Debug.Assert(offset < int.MaxValue);
                    Array.Copy(m_rgchBuf, checked ((int)offset), buffer, offsetInBuffer, count);
                    break;
                }
            }
            return(count);
        }
Beispiel #2
0
        // Read data of specified length from specified offset into a buffer

        public long Read(long offset, char[] buffer, int offsetInBuffer, int count)
        {
            if (IsNull)
            {
                throw new SqlNullValueException();
            }

            // Validate the arguments
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (offset > Length || offset < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offset));
            }

            if (offsetInBuffer > buffer.Length || offsetInBuffer < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(offsetInBuffer));
            }

            if (count < 0 || count > buffer.Length - offsetInBuffer)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            // Adjust count based on data length
            if (count > Length - offset)
            {
                count = (int)(Length - offset);
            }

            if (count != 0)
            {
                switch (_state)
                {
                case SqlBytesCharsState.Stream:
                    if (_stream.Position != offset)
                    {
                        _stream.Seek(offset, SeekOrigin.Begin);
                    }
                    _stream.Read(buffer, offsetInBuffer, count);
                    break;

                default:
                    Array.Copy(_rgchBuf, offset, buffer, offsetInBuffer, count);
                    break;
                }
            }
            return(count);
        }