2 // System.Data.SqlTypes.SqlInt16
5 // Tim Coleman <tim@timcoleman.com>
7 // (C) Copyright 2002 Tim Coleman
12 namespace System.Data.SqlTypes
14 public struct SqlInt16 : INullable, IComparable
20 public static readonly SqlInt16 MaxValue = new SqlInt16 (32767);
21 public static readonly SqlInt16 MinValue = new SqlInt16 (-32768);
22 public static readonly SqlInt16 Null;
23 public static readonly SqlInt16 Zero = new SqlInt16 (0);
29 public SqlInt16 (short value)
39 get { return (bool) (this == Null); }
45 throw new SqlNullValueException ();
55 public static SqlInt16 Add (SqlInt16 x, SqlInt16 y)
60 public static SqlInt16 BitwiseAnd (SqlInt16 x, SqlInt16 y)
65 public static SqlInt16 BitwiseOr (SqlInt16 x, SqlInt16 y)
70 public int CompareTo (object value)
74 else if (!(value is SqlInt16))
75 throw new ArgumentException (Locale.GetText ("Value is not a System.Data.SqlTypes.SqlInt16"));
76 else if (value.IsNull)
79 return value.CompareTo (value.Value);
82 public static SqlInt16 Divide (SqlInt16 x, SqlInt16 y)
87 public override bool Equals (object value)
89 if (!(value is SqlInt16))
92 return (bool) (this == value);
95 public static SqlBoolean Equals (SqlInt16 x, SqlInt16 y)
100 public override int GetHashCode ()
105 public static SqlBoolean GreaterThan (SqlInt16 x, SqlInt16 y)
110 public static SqlBoolean GreaterThanOrEqual (SqlInt16 x, SqlInt16 y)
115 public static SqlBoolean LessThan (SqlInt16 x, SqlInt16 y)
120 public static SqlBoolean LessThanOrEqual (SqlInt16 x, SqlInt16 y)
125 public static SqlInt16 Mod (SqlInt16 x, SqlInt16 y)
130 public static SqlInt16 Multiply (SqlInt16 x, SqlInt16 y)
135 public static SqlBoolean NotEquals (SqlInt16 x, SqlInt16 y)
140 public static SqlInt16 OnesComplement (SqlInt16 x)
146 public static SqlInt16 Parse (string s)
148 throw new NotImplementedException ();
151 public static SqlInt16 Subtract (SqlInt16 x, SqlInt16 y)
156 public SqlBoolean ToSqlBoolean ()
158 return ((SqlBoolean)this);
161 public SqlByte ToSqlByte ()
163 return ((SqlByte)this);
166 public SqlDecimal ToSqlDecimal ()
168 return ((SqlDecimal)this);
171 public SqlDouble ToSqlDouble ()
173 return ((SqlDouble)this);
176 public SqlInt32 ToSqlInt32 ()
178 return ((SqlInt32)this);
181 public SqlInt64 ToSqlInt64 ()
183 return ((SqlInt64)this);
186 public SqlMoney ToSqlMoney ()
188 return ((SqlMoney)this);
191 public SqlSingle ToSqlSingle ()
193 return ((SqlSingle)this);
196 public SqlString ToSqlString ()
198 return ((SqlString)this);
201 public override string ToString ()
206 return value.ToString ();
209 public static SqlInt16 Xor (SqlInt16 x, SqlInt16 y)
214 public static SqlInt16 operator + (SqlInt16 x, SqlInt16 y)
216 return new SqlInt16 ((short) (x.Value + y.Value));
219 public static SqlInt16 operator & (SqlInt16 x, SqlInt16 y)
221 return new SqlInt16 ((short) (x.value & y.Value));
224 public static SqlInt16 operator | (SqlInt16 x, SqlInt16 y)
226 return new SqlInt16 ((short) (x | y));
229 public static SqlInt16 operator / (SqlInt16 x, SqlInt16 y)
231 return new SqlInt16 ((short) (x.Value / y.Value));
234 public static SqlBoolean operator == (SqlInt16 x, SqlInt16 y)
236 if (x.IsNull || y.IsNull)
237 return SqlBoolean.Null;
239 return new SqlBoolean (x.Value == y.Value);
242 public static SqlInt16 operator ^ (SqlInt16 x, SqlInt16 y)
244 return new SqlInt16 ((short) (x.Value ^ y.Value));
247 public static SqlBoolean operator > (SqlInt16 x, SqlInt16 y)
249 if (x.IsNull || y.IsNull)
250 return SqlBoolean.Null;
252 return new SqlBoolean (x.Value > y.Value);
255 public static SqlBoolean operator >= (SqlInt16 x, SqlInt16 y)
257 if (x.IsNull || y.IsNull)
258 return SqlBoolean.Null;
260 return new SqlBoolean (x.Value >= y.Value);
263 public static SqlBoolean operator != (SqlInt16 x, SqlInt16 y)
265 if (x.IsNull || y.IsNull)
266 return SqlBoolean.Null;
268 return new SqlBoolean (!(x.Value == y.Value));
271 public static SqlBoolean operator < (SqlInt16 x, SqlInt16 y)
273 if (x.IsNull || y.IsNull)
274 return SqlBoolean.Null;
276 return new SqlBoolean (x.Value < y.Value);
279 public static SqlBoolean operator <= (SqlInt16 x, SqlInt16 y)
281 if (x.IsNull || y.IsNull)
282 return SqlBoolean.Null;
284 return new SqlBoolean (x.Value <= y.Value);
287 public static SqlInt16 operator % (SqlInt16 x, SqlInt16 y)
289 return new SqlInt16 ((short) (x.Value % y.Value));
292 public static SqlInt16 operator * (SqlInt16 x, SqlInt16 y)
294 return new SqlInt16 ((short) (x.Value * y.Value));
297 public static SqlInt16 operator ~ (SqlInt16 x)
299 return new SqlInt16 ((short) (~x.Value));
302 public static SqlInt16 operator - (SqlInt16 x, SqlInt16 y)
304 return new SqlInt16 ((short) (x.Value - y.Value));
307 public static SqlInt16 operator - (SqlInt16 n)
309 return new SqlInt16 ((short) (-n.Value));
312 public static explicit operator SqlInt16 (SqlBoolean x)
317 return new SqlInt16 ((short)x.ByteValue);
320 public static explicit operator SqlInt16 (SqlDecimal x)
325 return new SqlInt16 ((short)x.Value);
328 public static explicit operator SqlInt16 (SqlDouble x)
333 return new SqlInt16 ((short)x.Value);
336 public static explicit operator short (SqlInt16 x)
341 public static explicit operator SqlInt16 (SqlInt32 x)
346 return new SqlInt16 ((short)x.Value);
349 public static explicit operator SqlInt16 (SqlInt64 x)
354 return new SqlInt16 ((short)x.Value);
357 public static explicit operator SqlInt16 (SqlMoney x)
362 return new SqlInt16 ((short)x.Value);
365 public static explicit operator SqlInt16 (SqlSingle x)
370 return new SqlInt16 ((short)x.Value);
374 public static explicit operator SqlInt16 (SqlString x)
376 throw new NotImplementedException ();
379 public static implicit operator SqlInt16 (short x)
381 return new SqlInt16 (x);
384 public static implicit operator SqlInt16 (SqlByte x)
389 return new SqlInt16 ((short)x.Value);