25 namespace Deveel.Data.Types {
28 public const int DefaultMaxSize = Int16.MaxValue;
31 : this(typeCode, DefaultMaxSize) {
35 : base(
"BINARY", typeCode) {
37 AssertIsBinary(typeCode);
46 get {
return MaxSize; }
49 public override bool IsStorable {
53 public int MaxSize {
get;
private set; }
55 public override bool IsIndexable {
60 if (!IsBinaryType(sqlType))
61 throw new ArgumentException(
String.Format(
"The SQL type {0} is not a BINARY", sqlType));
77 return typeof (Stream);
81 var sb =
new StringBuilder(Name);
83 sb.AppendFormat(
"({0})", MaxSize);
90 throw new InvalidCastException();
92 var b = binary.First();
94 throw new InvalidCastException();
107 casted = ToBoolean(binary);
111 throw new InvalidCastException();
119 var binary = (SqlBinary) obj;
120 return 1 + 4 + (int) binary.Length;
122 throw new NotImplementedException();
125 throw new NotSupportedException();
129 var writer =
new BinaryWriter(stream);
132 var bin = (SqlBinary) obj;
133 writer.Write((byte)1);
134 writer.Write((
int)bin.Length);
135 writer.Write(bin.ToByteArray());
137 var lob = (SqlLongBinary) obj;
139 writer.Write((byte) 2);
143 throw new NotImplementedException();
145 base.SerializeObject(stream, obj);
150 var reader =
new BinaryReader(stream);
152 var type = reader.ReadByte();
154 var length = reader.ReadInt32();
155 var bytes = reader.ReadBytes(length);
162 throw new FormatException();
override int ColumnSizeOf(ISqlObject obj)
override Type GetObjectType()
override string ToString()
A long string in the system.
Implements a BINARY object that handles a limited number of bytes, not exceding MaxLength.
override DataObject CastTo(DataObject value, SqlType destType)
Converts the given object value to a SqlType specified.
static void AssertIsBinary(SqlTypeCode sqlType)
void SetValue(string key, Type type, object value)
ISqlObject Value
Gets the underlined value that is handled.
long Length
Gets the raw length of the binary object.
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
BinaryType(ObjectData data)
Defines the contract for a valid SQL Object
static bool IsBinaryType(SqlTypeCode sqlType)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
override Type GetRuntimeType()
BinaryType(SqlTypeCode typeCode)
Defines the properties of a specific SQL Type and handles the values compatible.
override void GetData(SerializeData data)
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
override void SerializeObject(Stream stream, ISqlObject obj)
override bool IsCacheable(ISqlObject value)
override ISqlObject DeserializeObject(Stream stream)
Defines the required contract of a SQL BINARY object
BinaryType(SqlTypeCode typeCode, int maxSize)
SqlBoolean ToBoolean(ISqlBinary binary)