19 using System.Collections.Generic;
22 namespace Deveel.Data.Sql.Objects {
36 public const int MaxLength = Int32.MaxValue - 1;
39 : this(source, source == null ? 0 : source.Length) {
43 : this(source, 0, length) {
46 public SqlBinary(byte[] source,
int offset,
int length)
51 if (length > MaxLength)
52 throw new ArgumentOutOfRangeException(
"length");
54 bytes =
new byte[length];
55 Array.Copy(source, offset, bytes, 0, length);
59 int IComparable.CompareTo(
object obj) {
60 return (
this as IComparable<ISqlObject>).CompareTo((
ISqlObject) obj);
63 int IComparable<ISqlObject>.CompareTo(
ISqlObject other) {
64 throw new NotSupportedException();
69 get {
return bytes == null; }
78 throw new NotImplementedException();
81 IEnumerator IEnumerable.GetEnumerator() {
82 return GetEnumerator();
87 get {
return bytes == null ? 0L : bytes.Length; }
95 return new MemoryStream(bytes,
false);
106 var destArray =
new byte[bytes.Length];
107 Array.Copy(bytes, 0, destArray, 0, bytes.Length);
Implements a BINARY object that handles a limited number of bytes, not exceding MaxLength.
Stream GetInput()
Gets an object used to read the contents of the binary
Defines the contract for a valid SQL Object
byte[] ToByteArray()
Returns an array of bytes representing the contents of the binary.
SqlBinary(byte[] source, int length)
SqlBinary(byte[] source, int offset, int length)
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
Defines the required contract of a SQL BINARY object
IEnumerator< byte > GetEnumerator()