forked from tSQLt-org/tSQLt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataTypeByteOrdered.cs
More file actions
54 lines (44 loc) · 1.41 KB
/
Copy pathDataTypeByteOrdered.cs
File metadata and controls
54 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Data.SqlTypes;
using System.IO;
using Microsoft.SqlServer.Server;
namespace tSQLtTestUtilCLR
{
[SqlUserDefinedType(Format.UserDefined, MaxByteSize = 5, IsFixedLength = true, IsByteOrdered = true)]
public class DataTypeByteOrdered : INullable, IBinarySerialize, IComparable
{
private int _i;
public bool IsNull { get; private set; }
public override string ToString()
{
return "<<DataTypeByteOrdered>>";
}
public int CompareTo(object obj)
{
if (!(obj is DataTypeByteOrdered))
{
throw new ArgumentException("Object is not a DataTypeByteOrdered.");
}
var p2 = (DataTypeByteOrdered)obj;
return _i.CompareTo(p2._i);
}
public static DataTypeByteOrdered Parse(SqlString s)
{
return new DataTypeByteOrdered() { IsNull = (s.IsNull), _i = int.Parse(s.Value) };
}
public static DataTypeByteOrdered Null
{
get { return new DataTypeByteOrdered() { IsNull = true }; }
}
public void Read(BinaryReader r)
{
IsNull = r.ReadBoolean();
_i = r.ReadInt32();
}
public void Write(BinaryWriter w)
{
w.Write(IsNull);
w.Write(_i);
}
}
}