WebApplications.Testing.Data.ObjectRecord.GetBytes C# (CSharp) Method

GetBytes() public method

public GetBytes ( int i, long fieldOffset, [ buffer, int bufferoffset, int length ) : long
i int
fieldOffset long
buffer [
bufferoffset int
length int
return long
        public long GetBytes(int i, long fieldOffset, [CanBeNull] byte[] buffer, int bufferoffset, int length)
        {
            if ((i < 0) ||
                (i > FieldCount))
                throw new IndexOutOfRangeException(i.ToString(CultureInfo.InvariantCulture));
            if (buffer == null)
                return 0;

            object o = _columnValues[i];
            if (o == null)
                throw new SqlNullValueException();
            if (!(o is byte[]))
                throw new InvalidCastException();
            byte[] bytes = (byte[])o;
            length = (bytes.Length - fieldOffset) < length ? (int)(bytes.Length - fieldOffset) : length;
            Debug.Assert(length >= 0);
            Array.Copy(bytes, fieldOffset, buffer, bufferoffset, length);
            return length;
        }