2 // Mono.Data.TdsTypes.TdsGuid
5 // Tim Coleman <tim@timcoleman.com>
7 // (C) Copyright Tim Coleman, 2002
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using Mono
.Data
.TdsClient
;
33 using System
.Data
.SqlTypes
;
34 using System
.Globalization
;
36 namespace Mono
.Data
.TdsTypes
{
37 public struct TdsGuid
: INullable
, IComparable
45 public static readonly TdsGuid Null
;
51 public TdsGuid (byte[] value)
53 this.value = new Guid (value);
57 public TdsGuid (Guid g
)
63 public TdsGuid (string s
)
65 this.value = new Guid (s
);
69 public TdsGuid (int a
, short b
, short c
, byte d
, byte e
, byte f
, byte g
, byte h
, byte i
, byte j
, byte k
)
71 this.value = new Guid (a
, b
, c
, d
, e
, f
, g
, h
, i
, j
, k
);
80 get { return !notNull; }
86 throw new TdsNullValueException ("The property contains Null.");
96 public int CompareTo (object value)
100 else if (!(value is TdsGuid
))
101 throw new ArgumentException (Locale
.GetText ("Value is not a System.Data.TdsTypes.TdsGuid"));
102 else if (((TdsGuid
)value).IsNull
)
105 return this.value.CompareTo (((TdsGuid
)value).Value
);
108 public override bool Equals (object value)
110 if (!(value is TdsGuid
))
113 return (bool) (this == (TdsGuid
)value);
116 public static TdsBoolean
Equals (TdsGuid x
, TdsGuid y
)
122 public override int GetHashCode ()
127 public static TdsBoolean
GreaterThan (TdsGuid x
, TdsGuid y
)
132 public static TdsBoolean
GreaterThanOrEqual (TdsGuid x
, TdsGuid y
)
137 public static TdsBoolean
LessThan (TdsGuid x
, TdsGuid y
)
142 public static TdsBoolean
LessThanOrEqual (TdsGuid x
, TdsGuid y
)
147 public static TdsBoolean
NotEquals (TdsGuid x
, TdsGuid y
)
153 public static TdsGuid
Parse (string s
)
155 throw new NotImplementedException ();
159 public byte[] ToByteArray()
161 throw new NotImplementedException ();
164 public TdsBinary
ToTdsBinary ()
166 return ((TdsBinary
)this);
169 public TdsString
ToTdsString ()
171 return ((TdsString
)this);
174 public override string ToString ()
179 return value.ToString ();
182 public static TdsBoolean
operator == (TdsGuid x
, TdsGuid y
)
184 if (x
.IsNull
|| y
.IsNull
) return TdsBoolean
.Null
;
185 return new TdsBoolean (x
.Value
== y
.Value
);
189 public static TdsBoolean
operator > (TdsGuid x
, TdsGuid y
)
191 throw new NotImplementedException ();
195 public static TdsBoolean
operator >= (TdsGuid x
, TdsGuid y
)
197 throw new NotImplementedException ();
200 public static TdsBoolean
operator != (TdsGuid x
, TdsGuid y
)
202 if (x
.IsNull
|| y
.IsNull
) return TdsBoolean
.Null
;
203 return new TdsBoolean (!(x
.Value
== y
.Value
));
207 public static TdsBoolean
operator < (TdsGuid x
, TdsGuid y
)
209 throw new NotImplementedException ();
213 public static TdsBoolean
operator <= (TdsGuid x
, TdsGuid y
)
215 throw new NotImplementedException ();
219 public static explicit operator TdsGuid (TdsBinary x
)
221 throw new NotImplementedException ();
224 public static explicit operator Guid (TdsGuid x
)
230 public static explicit operator TdsGuid (TdsString x
)
232 throw new NotImplementedException ();
235 public static implicit operator TdsGuid (Guid x
)
237 return new TdsGuid (x
);