+2002-05-03 Rodrigo Moya <rodrigo@ximian.com>
+
+ * System.Data.SqlTypes/SqlBinary.cs:
+ * System.Data.SqlTypes/SqlBoolean.cs:
+ * System.Data.SqlTypes/SqlInt32.cs:
+ * System.Data.SqlTypes/SqlString.cs: more implementation, by
+ Tim Coleman <tcoleman@opentext.com>.
+
2002-05-03 Daniel Morgan <danmorg@sc.rr.com>
* Test/TestExecuteScalar.cs: added test for
//
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
+// Tim Coleman (tim@timcoleman.com)
//
// (C) Ximian, Inc.
//
/// </summary>
public struct SqlBinary : INullable, IComparable
{
- public static readonly SqlBinary Null;
+ private byte[] value;
+ public static readonly SqlBinary Null = new SqlBinary (null);
- [MonoTODO]
- public SqlBinary (byte[] value) {
- throw new NotImplementedException ();
+ public SqlBinary (byte[] value)
+ {
+ this.value = value;
}
[MonoTODO]
- public int CompareTo (object value) {
+ public int CompareTo (object value)
+ {
throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBinary Concat (SqlBinary x, SqlBinary y) {
- throw new NotImplementedException ();
+ public static SqlBinary Concat (SqlBinary x, SqlBinary y)
+ {
+ return (x + y);
}
[MonoTODO]
- public override bool Equals (object value) {
+ public override bool Equals (object value)
+ {
throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBoolean Equals(SqlBinary x, SqlBinary y) {
- throw new NotImplementedException ();
+ public static SqlBoolean Equals(SqlBinary x, SqlBinary y)
+ {
+ return (x == y);
}
[MonoTODO]
- public override int GetHashCode () {
+ public override int GetHashCode ()
+ {
throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBoolean GreaterThan (SqlBinary x, SqlBinary y) {
- throw new NotImplementedException ();
+ public static SqlBoolean GreaterThan (SqlBinary x, SqlBinary y)
+ {
+ return (x > y);
}
- [MonoTODO]
- public static SqlBoolean GreaterThanOrEqual (SqlBinary x, SqlBinary y) {
- throw new NotImplementedException ();
+ public static SqlBoolean GreaterThanOrEqual (SqlBinary x, SqlBinary y)
+ {
+ return (x >= y);
}
- [MonoTODO]
- public static SqlBoolean LessThan (SqlBinary x, SqlBinary y) {
- throw new NotImplementedException ();
+ public static SqlBoolean LessThan (SqlBinary x, SqlBinary y)
+ {
+ return (x < y);
}
[MonoTODO]
- public static SqlBoolean LessThanOrEqual (SqlBinary x, SqlBinary y) {
- throw new NotImplementedException ();
+ public static SqlBoolean LessThanOrEqual (SqlBinary x, SqlBinary y)
+ {
+ return (x <= y);
}
- [MonoTODO]
- public static SqlBoolean NotEquals (SqlBinary x, SqlBinary y) {
- throw new NotImplementedException ();
+ public static SqlBoolean NotEquals (SqlBinary x, SqlBinary y)
+ {
+ return (x != y);
}
- [MonoTODO]
- public SqlGuid ToSqlGuid () {
- throw new NotImplementedException ();
+ public SqlGuid ToSqlGuid ()
+ {
+ return new SqlGuid (value);
}
[MonoTODO]
- public override string ToString () {
+ public override string ToString ()
+ {
throw new NotImplementedException ();
}
- [MonoTODO]
public bool IsNull {
- get { throw new NotImplementedException (); }
+ get { return (value == null); }
}
- [MonoTODO]
public byte this[int index] {
- get { throw new NotImplementedException (); }
+ get { return value[index]; }
}
[MonoTODO]
get { throw new NotImplementedException (); }
}
- [MonoTODO]
- public byte[] Value {
- get { throw new NotImplementedException (); }
+ public byte[] Value
+ {
+ get { return value; }
}
[MonoTODO]
- public static SqlBinary operator + (SqlBinary x, SqlBinary y) {
+ public static SqlBinary operator + (SqlBinary x, SqlBinary y)
+ {
throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator == (SqlBinary x, SqlBinary y) {
+ public static SqlBoolean operator == (SqlBinary x, SqlBinary y)
+ {
throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator > (SqlBinary x, SqlBinary y) {
+ public static SqlBoolean operator > (SqlBinary x, SqlBinary y)
+ {
throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator >= (SqlBinary x, SqlBinary y) {
+ public static SqlBoolean operator >= (SqlBinary x, SqlBinary y)
+ {
throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator != (SqlBinary x, SqlBinary y) {
+ public static SqlBoolean operator != (SqlBinary x, SqlBinary y)
+ {
throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator < (SqlBinary x, SqlBinary y) {
+ public static SqlBoolean operator < (SqlBinary x, SqlBinary y)
+ {
throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator <= (SqlBinary x, SqlBinary y) {
+ public static SqlBoolean operator <= (SqlBinary x, SqlBinary y)
+ {
throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator byte[] (SqlBinary x) {
- throw new NotImplementedException ();
+ public static explicit operator byte[] (SqlBinary x)
+ {
+ return x.Value;
}
- [MonoTODO]
- public static explicit operator SqlBinary (SqlGuid x) {
- throw new NotImplementedException ();
+ public static explicit operator SqlBinary (SqlGuid x)
+ {
+ return x.ToSqlBinary ();
}
- [MonoTODO]
- public static implicit operator SqlBinary (byte[] x) {
- throw new NotImplementedException ();
+ public static implicit operator SqlBinary (byte[] x)
+ {
+ return new SqlBinary (x);
}
}
}
-
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
// Daniel Morgan (danmorg@sc.rr.com)
+// Tim Coleman (tim@timcoleman.com)
//
// (C) Ximian, Inc. 2002
//
/// Represents an integer value that is either 1 or 0
/// to be stored in or retrieved from a database.
/// </summary>
- public struct SqlBoolean : INullable, IComparable {
+ public struct SqlBoolean : INullable, IComparable
+ {
#region Fields
- // FIXME: populate the static Fields?
+ private byte value;
- // Value
- public static readonly SqlBoolean False;
-
- // Value
+ public static readonly SqlBoolean False = new SqlBoolean (false);
+ [MonoTODO]
public static readonly SqlBoolean Null;
- // ByteValue
- public static readonly SqlBoolean One;
+ public static readonly SqlBoolean One = new SqlBoolean (1);
- // Value
- public static readonly SqlBoolean True;
+ public static readonly SqlBoolean True = new SqlBoolean (true);
+
+ public static readonly SqlBoolean Zero = new SqlBoolean (0);
- // ByteValue
- public static readonly SqlBoolean Zero;
#endregion // Fields
#region Constructors
- [MonoTODO]
- public SqlBoolean(bool value) {
- throw new NotImplementedException ();
+ public SqlBoolean (bool value)
+ {
+ this.value = (byte) (value ? 1 : 0);
}
- [MonoTODO]
- public SqlBoolean(int value) {
- throw new NotImplementedException ();
+ public SqlBoolean (int value)
+ {
+ this.value = (byte) (value != 0 ? 1 : 0);
}
#endregion // Constructors
#region Properties
public byte ByteValue {
- [MonoTODO]
- get {
- throw new NotImplementedException ();
- }
+ get { return value; }
}
public bool IsFalse {
- [MonoTODO]
- get {
- throw new NotImplementedException ();
+ get {
+ if (this.IsNull) return false;
+ else return (value == 0);
}
}
public bool IsNull {
- [MonoTODO]
- get {
- throw new NotImplementedException ();
- }
+ get { return (bool) (this == SqlBoolean.Null); }
}
public bool IsTrue {
- [MonoTODO]
- get {
- throw new NotImplementedException ();
+ get {
+ if (this.IsNull) return false;
+ else return (value != 0);
}
}
public bool Value {
- [MonoTODO]
- get {
- throw new NotImplementedException ();
+ get {
+ if (this.IsNull)
+ throw new SqlNullValueException( "The property is set to null.");
+ else
+ return this.IsTrue;
}
}
#endregion // Properties
- [MonoTODO]
- public static SqlBoolean And(SqlBoolean x, SqlBoolean y) {
- throw new NotImplementedException ();
+ public static SqlBoolean And (SqlBoolean x, SqlBoolean y)
+ {
+ return (x & y);
}
[MonoTODO]
- public int CompareTo(object value) {
+ public int CompareTo (object value)
+ {
throw new NotImplementedException ();
}
[MonoTODO]
- public override bool Equals(object value) {
+ public override bool Equals(object value)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBoolean Equals(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean Equals(SqlBoolean x, SqlBoolean y)
+ {
+ return (x == y);
}
- [MonoTODO]
- public override int GetHashCode() {
+ public override int GetHashCode()
+ {
+ return (int)value;
}
- [MonoTODO]
- public static SqlBoolean NotEquals(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean NotEquals(SqlBoolean x, SqlBoolean y)
+ {
+ return (x != y);
}
- [MonoTODO]
- public static SqlBoolean OnesComplement(SqlBoolean x) {
+ public static SqlBoolean OnesComplement(SqlBoolean x)
+ {
+ return ~x;
}
- [MonoTODO]
- public static SqlBoolean Or(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean Or(SqlBoolean x, SqlBoolean y)
+ {
+ return (x | y);
}
- [MonoTODO]
- public static SqlBoolean Parse(string s) {
+ public static SqlBoolean Parse(string s)
+ {
+ return new SqlBoolean (Boolean.Parse (s));
}
- [MonoTODO]
- public SqlByte ToSqlByte() {
+ public SqlByte ToSqlByte()
+ {
+ return new SqlByte (value);
}
// **************************************************
// Conversion from SqlBoolean to other SqlTypes
// **************************************************
- [MonoTODO]
- public SqlDecimal ToSqlDecimal() {
+ public SqlDecimal ToSqlDecimal()
+ {
+ return ((SqlDecimal)value);
}
- [MonoTODO]
- public SqlDouble ToSqlDouble() {
+ public SqlDouble ToSqlDouble()
+ {
+ return ((SqlDouble)value);
}
- [MonoTODO]
- public SqlInt16 ToSqlInt16() {
+ public SqlInt16 ToSqlInt16()
+ {
+ return ((SqlInt16)value);
}
- [MonoTODO]
- public SqlInt32 ToSqlInt32() {
+ public SqlInt32 ToSqlInt32()
+ {
+ return ((SqlInt32)value);
}
- [MonoTODO]
- public SqlInt64 ToSqlInt64() {
+ public SqlInt64 ToSqlInt64()
+ {
+ return ((SqlInt64)value);
}
- [MonoTODO]
- public SqlMoney ToSqlMoney() {
+ public SqlMoney ToSqlMoney()
+ {
+ return ((SqlMoney)value);
}
- [MonoTODO]
- public SqlSingle ToSqlSingle() {
+ public SqlSingle ToSqlSingle()
+ {
+ return ((SqlSingle)value);
}
- [MonoTODO]
- public SqlString ToSqlString() {
+ public SqlString ToSqlString()
+ {
+ return new SqlString (this.ToString());
}
[MonoTODO]
- public override string ToString() {
+ public override string ToString()
+ {
+ throw new NotImplementedException ();
}
// Bitwise exclusive-OR (XOR)
- [MonoTODO]
- public static SqlBoolean Xor(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean Xor(SqlBoolean x, SqlBoolean y)
+ {
+ return (x ^ y);
}
// **************************************************
// **************************************************
// Bitwise AND
- [MonoTODO]
- public static SqlBoolean operator &(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean operator & (SqlBoolean x, SqlBoolean y)
+ {
+ return new SqlBoolean (x.Value & y.Value);
}
// Bitwise OR
- [MonoTODO]
- public static SqlBoolean operator |(SqlBoolean x, SqlBoolean y) {\r
+ public static SqlBoolean operator | (SqlBoolean x, SqlBoolean y)
+ {
+ return new SqlBoolean (x.Value | y.Value);
+
}
// Compares two instances for equality
- [MonoTODO]
- public static SqlBoolean operator ==(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean operator == (SqlBoolean x, SqlBoolean y)
+ {
+ return new SqlBoolean (x.Value == y.Value);
}
// Bitwize exclusive-OR (XOR)
- [MonoTODO]
- public static SqlBoolean operator ^(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean operator ^ (SqlBoolean x, SqlBoolean y)
+ {
+ return new SqlBoolean (x.Value ^ y.Value);
}
// test Value of SqlBoolean to determine it is false.
- [MonoTODO]
- public static bool operator false(SqlBoolean x) {
+ public static bool operator false (SqlBoolean x)
+ {
+ return x.IsFalse;
}
// in-equality
- [MonoTODO]
- public static SqlBoolean operator !=(SqlBoolean x, SqlBoolean y) {
+ public static SqlBoolean operator != (SqlBoolean x, SqlBoolean y)
+ {
+ return new SqlBoolean (x.Value != y.Value);
}
// Logical NOT
- [MonoTODO]
- public static SqlBoolean operator !(SqlBoolean x) {
+ public static SqlBoolean operator ! (SqlBoolean x)
+ {
+ return new SqlBoolean (!x.Value);
}
// One's Complement
- [MonoTODO]
- public static SqlBoolean operator ~(SqlBoolean x) {
+ public static SqlBoolean operator ~ (SqlBoolean x)
+ {
+ return new SqlBoolean (~x.ByteValue);
}
// test to see if value is true
- [MonoTODO]
- public static bool operator true(SqlBoolean x) {
+ public static bool operator true (SqlBoolean x)
+ {
+ return x.IsTrue;
}
// ****************************************
// SqlBoolean to Boolean
- [MonoTODO]
- public static explicit operator bool(SqlBoolean x) {
+ public static explicit operator bool (SqlBoolean x)
+ {
+ return x.Value;
}
// SqlByte to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlByte x) {
+ public static explicit operator SqlBoolean (SqlByte x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlDecimal to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlDecimal x) {
+ public static explicit operator SqlBoolean (SqlDecimal x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlDouble to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlDouble x) {
+ public static explicit operator SqlBoolean (SqlDouble x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlInt16 to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlInt16 x) {
+ public static explicit operator SqlBoolean (SqlInt16 x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlInt32 to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlInt32 x) {
+ public static explicit operator SqlBoolean (SqlInt32 x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlInt64 to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlInt64 x) {
+ public static explicit operator SqlBoolean (SqlInt64 x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlMoney to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlMoney x) {
+ public static explicit operator SqlBoolean (SqlMoney x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlSingle to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlSingle x) {
+ public static explicit operator SqlBoolean (SqlSingle x)
+ {
+ return x.ToSqlBoolean ();
}
// SqlString to SqlBoolean
- [MonoTODO]
- public static explicit operator SqlBoolean(SqlString x) {
+ public static explicit operator SqlBoolean (SqlString x)
+ {
+ return x.ToSqlBoolean ();
}
// Boolean to SqlBoolean
- [MonoTODO]
- public static implicit operator SqlBoolean(bool x) {
+ public static implicit operator SqlBoolean (bool x)
+ {
+ return new SqlBoolean (x);
}
}
}
namespace System.Data.SqlTypes
{
- /// <summary>\r
- /// a 32-bit signed integer to be used in reading or writing\r
- /// of data from a database\r
+ /// <summary>
+ /// a 32-bit signed integer to be used in reading or writing
+ /// of data from a database
/// </summary>
- public struct SqlInt32 : INullable, IComparable {
- // FIXME: Fields need to be initialized
+ public struct SqlInt32 : INullable, IComparable
+ {
+ #region Fields
- // Constructor
- [MonoTODO]
- public SqlInt32(int value) {
- }
-
- // Fields (Constants)
+ private int value;
+ [MonoTODO]
public static readonly SqlInt32 MaxValue;
+ [MonoTODO]
public static readonly SqlInt32 MinValue;
+ [MonoTODO]
public static readonly SqlInt32 Null;
+ [MonoTODO]
public static readonly SqlInt32 Zero;
+ #endregion
+
+ #region Constructors
+
+ public SqlInt32(int value)
+ {
+ this.value = value;
+ }
+
+ #endregion
+
// Public Properties
public bool IsNull {
- [MonoTODO]
- get {
- } \r
+ get { return (bool) (this == SqlInt32.Null); }
}
public int Value {
- [MonoTODO]
- get {
- }
+ get { return value; }
}
// Public Methods
- [MonoTODO]
- public static SqlInt32 Add(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 Add(SqlInt32 x, SqlInt32 y)
+ {
+ return (x + y);
}
- [MonoTODO]
- public static SqlInt32 BitwiseAnd(SqlInt32 x, SqlInt32 y) {\r
- }\r
+ public static SqlInt32 BitwiseAnd(SqlInt32 x, SqlInt32 y)
+ {
+ return (x & y);
+ }
- [MonoTODO]
- public static SqlInt32 BitwiseOr(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 BitwiseOr(SqlInt32 x, SqlInt32 y)
+ {
+ return (x | y);
}
[MonoTODO]
- public int CompareTo(object value) {
+ public int CompareTo(object value)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlInt32 Divide(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 Divide(SqlInt32 x, SqlInt32 y)
+ {
+ return (x / y);
}
[MonoTODO]
- public override bool Equals(object value) {
+ public override bool Equals(object value)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBoolean Equals(SqlInt32 x, SqlInt32 y) {
+ public static SqlBoolean Equals(SqlInt32 x, SqlInt32 y)
+ {
+ return (x == y);
}
- [MonoTODO]
- public override int GetHashCode() {
+ public override int GetHashCode()
+ {
+ return value;
}
- [MonoTODO]
- public static SqlBoolean GreaterThan(SqlInt32 x,\r
- SqlInt32 y) {
+ public static SqlBoolean GreaterThan (SqlInt32 x, SqlInt32 y)
+ {
+ return (x > y);
}
- [MonoTODO]
- public static SqlBoolean GreaterThanOrEqual(SqlInt32 x,\r
- SqlInt32 y) {
+ public static SqlBoolean GreaterThanOrEqual (SqlInt32 x, SqlInt32 y)
+ {
+ return (x >= y);
}
- [MonoTODO]
- public static SqlBoolean LessThan(SqlInt32 x, SqlInt32 y) {
+ public static SqlBoolean LessThan(SqlInt32 x, SqlInt32 y)
+ {
+ return (x < y);
}
- [MonoTODO]
- public static SqlBoolean LessThanOrEqual(SqlInt32 x,\r
- SqlInt32 y) {
+ public static SqlBoolean LessThanOrEqual(SqlInt32 x, SqlInt32 y)
+ {
+ return (x <= y);
}
- [MonoTODO]
- public static SqlInt32 Mod(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 Mod(SqlInt32 x, SqlInt32 y)
+ {
+ return (x % y);
}
- [MonoTODO]
- public static SqlInt32 Multiply(SqlInt32 x,\r
- SqlInt32 y) {
+ public static SqlInt32 Multiply(SqlInt32 x, SqlInt32 y)
+ {
+ return (x * y);
}
- [MonoTODO]
- public static SqlBoolean NotEquals(SqlInt32 x,\r
- SqlInt32 y) {
+ public static SqlBoolean NotEquals(SqlInt32 x, SqlInt32 y)
+ {
+ return (x != y);
}
- [MonoTODO]
- public static SqlInt32 OnesComplement(SqlInt32 x) {
+ public static SqlInt32 OnesComplement(SqlInt32 x)
+ {
+ return ~x;
}
- [MonoTODO]
- public static SqlInt32 Parse(string s) {
+ public static SqlInt32 Parse(string s)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlInt32 Subtract(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 Subtract(SqlInt32 x, SqlInt32 y)
+ {
+ return (x - y);
}
// Type Conversions
- [MonoTODO]
- public SqlBoolean ToSqlBoolean() {
+ public SqlBoolean ToSqlBoolean()
+ {
+ return ((SqlBoolean)this);
}
- [MonoTODO]
- public SqlByte ToSqlByte() {
+ public SqlByte ToSqlByte()
+ {
+ return ((SqlByte)this);
}
- [MonoTODO]
- public SqlDecimal ToSqlDecimal() {
+ public SqlDecimal ToSqlDecimal()
+ {
+ return ((SqlDecimal)this);
}
- [MonoTODO]
- public SqlDouble ToSqlDouble() {
+ public SqlDouble ToSqlDouble()
+ {
+ return ((SqlDouble)this);
}
- [MonoTODO]
- public SqlInt16 ToSqlInt16() {
+ public SqlInt16 ToSqlInt16()
+ {
+ return ((SqlInt16)this);
}
- [MonoTODO]
- public SqlInt64 ToSqlInt64() {
+ public SqlInt64 ToSqlInt64()
+ {
+ return ((SqlInt64)this);
}
- [MonoTODO]
- public SqlMoney ToSqlMoney() {
+ public SqlMoney ToSqlMoney()
+ {
+ return ((SqlMoney)this);
}
- [MonoTODO]
- public SqlSingle ToSqlSingle() {
+ public SqlSingle ToSqlSingle()
+ {
+ return ((SqlSingle)this);
}
[MonoTODO]
- public override string ToString() {
+ public override string ToString()
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlInt32 Xor(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 Xor(SqlInt32 x, SqlInt32 y)
+ {
+ return (x ^ y);
}
// Public Operators
// Compute Addition
- [MonoTODO]
- public static SqlInt32 operator +(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator +(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value + y.Value);
}
// Bitwise AND
- [MonoTODO]
- public static SqlInt32 operator &(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator &(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value & y.Value);
}
// Bitwise OR
- [MonoTODO]
- public static SqlInt32 operator |(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator |(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value | y.Value);
}
// Compute Division
- [MonoTODO]
- public static SqlInt32 operator /(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator /(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value / y.Value);
}
// Compare Equality
- [MonoTODO]
- public static SqlBoolean operator ==(SqlInt32 x, SqlInt32 y) {
+ public static SqlBoolean operator ==(SqlInt32 x, SqlInt32 y)
+ {
+ if (x.IsNull || y.IsNull) return SqlBoolean.Null;
+ return new SqlBoolean (x.Value == y.Value);
}
// Bitwise Exclusive-OR (XOR)
- [MonoTODO]
- public static SqlInt32 operator ^(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator ^(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value ^ y.Value);
}
// > Compare
- [MonoTODO]
- public static SqlBoolean operator >(SqlInt32 x, SqlInt32 y) {
+ public static SqlBoolean operator >(SqlInt32 x, SqlInt32 y)
+ {
+ if (x.IsNull || y.IsNull) return SqlBoolean.Null;
+ return new SqlBoolean (x.Value > y.Value);
}
// >= Compare
- [MonoTODO]
- public static SqlBoolean operator >=(SqlInt32 x, SqlInt32 y) {
+ public static SqlBoolean operator >=(SqlInt32 x, SqlInt32 y)
+ {
+ if (x.IsNull || y.IsNull) return SqlBoolean.Null;
+ return new SqlBoolean (x.Value >= y.Value);
}
// != Inequality Compare
- [MonoTODO]
- public static SqlBoolean operator !=(SqlInt32 x, SqlInt32 y) {\r
- }\r
+ public static SqlBoolean operator !=(SqlInt32 x, SqlInt32 y)
+ {
+ if (x.IsNull || y.IsNull) return SqlBoolean.Null;
+ return new SqlBoolean (x.Value != y.Value);
+ }
// < Compare
- [MonoTODO]
- public static SqlBoolean operator <(SqlInt32 x, SqlInt32 y) {
+ public static SqlBoolean operator <(SqlInt32 x, SqlInt32 y)
+ {
+ if (x.IsNull || y.IsNull) return SqlBoolean.Null;
+ return new SqlBoolean (x.Value < y.Value);
}
// <= Compare
- [MonoTODO]
- public static SqlBoolean operator <=(SqlInt32 x, SqlInt32 y) {
+ public static SqlBoolean operator <=(SqlInt32 x, SqlInt32 y)
+ {
+ if (x.IsNull || y.IsNull) return SqlBoolean.Null;
+ return new SqlBoolean (x.Value <= y.Value);
}
// Compute Modulus
- [MonoTODO]
- public static SqlInt32 operator %(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator %(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value % y.Value);
}
// Compute Multiplication
- [MonoTODO]
- public static SqlInt32 operator *(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator *(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value * y.Value);
}
// Ones Complement
- [MonoTODO]
- public static SqlInt32 operator ~(SqlInt32 x) {
+ public static SqlInt32 operator ~(SqlInt32 x)
+ {
+ return new SqlInt32 (~x.Value);
}
// Subtraction
- [MonoTODO]
- public static SqlInt32 operator -(SqlInt32 x, SqlInt32 y) {
+ public static SqlInt32 operator -(SqlInt32 x, SqlInt32 y)
+ {
+ return new SqlInt32 (x.Value - y.Value);
}
// Negates the Value
- [MonoTODO]
- public static SqlInt32 operator -(SqlInt32 x) {
+ public static SqlInt32 operator -(SqlInt32 x)
+ {
+ return new SqlInt32 (-x.Value);
}
// Type Conversions
- [MonoTODO]
- public static explicit operator SqlInt32(SqlBoolean x) {
+ public static explicit operator SqlInt32(SqlBoolean x)
+ {
+ return new SqlInt32 ((int)x.ByteValue);
}
- [MonoTODO]
- public static explicit operator SqlInt32(SqlDecimal x) {
+ public static explicit operator SqlInt32(SqlDecimal x)
+ {
+ return new SqlInt32 ((int)x.Value);
}
- [MonoTODO]
- public static explicit operator SqlInt32(SqlDouble x) {
+ public static explicit operator SqlInt32(SqlDouble x)
+ {
+ return new SqlInt32 ((int)x.Value);
}
- [MonoTODO]
- public static explicit operator int(SqlInt32 x){
+ public static explicit operator int(SqlInt32 x)
+ {
+ return x.Value;
}
- [MonoTODO]
- public static explicit operator SqlInt32(SqlInt64 x) {
+ public static explicit operator SqlInt32(SqlInt64 x)
+ {
+ return new SqlInt32 ((int)x.Value);
}
- [MonoTODO]
- public static explicit operator SqlInt32(SqlMoney x) {
+ public static explicit operator SqlInt32(SqlMoney x)
+ {
+ return new SqlInt32 ((int)x.Value);
}
- [MonoTODO]
- public static explicit operator SqlInt32(SqlSingle x) {
+ public static explicit operator SqlInt32(SqlSingle x)
+ {
+ return new SqlInt32 ((int)x.Value);
}
[MonoTODO]
- public static explicit operator SqlInt32(SqlString x) {
+ public static explicit operator SqlInt32(SqlString x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static implicit operator SqlInt32(int x) {
+ public static implicit operator SqlInt32(int x)
+ {
+ return new SqlInt32 (x);
}
- [MonoTODO]
- public static implicit operator SqlInt32(SqlByte x) {
+ public static implicit operator SqlInt32(SqlByte x)
+ {
+ return new SqlInt32 ((int)x.Value);
}
- [MonoTODO]
- public static implicit operator SqlInt32(SqlInt16 x) {
+ public static implicit operator SqlInt32(SqlInt16 x)
+ {
+ return new SqlInt32 ((int)x.Value);
}
}
}
// Author:
// Rodrigo Moya (rodrigo@ximian.com)
// Daniel Morgan (danmorg@sc.rr.com)
+// Tim Coleman (tim@timcoleman.com)
//
// (C) Ximian, Inc. 2002
//
+using System;
+using System.Globalization;
+
namespace System.Data.SqlTypes
{
- /// <summary>\r
- /// A variable-length stream of characters \r
- /// to be stored in or retrieved from the database\r
+ /// <summary>
+ /// A variable-length stream of characters
+ /// to be stored in or retrieved from the database
/// </summary>
- public struct SqlString : INullable, IComparable {
+ public struct SqlString : INullable, IComparable
+ {
+
+ #region Fields
+
+ private string value;
+
+ public static readonly int BinarySort;
+
+ public static readonly int IgnoreCase;
- // FIXME: the static readonly fields need to be initlized
+ public static readonly int IgnoreKanaType;
+
+ public static readonly int IgnoreNonSpace;
+
+ public static readonly int IgnoreWidth;
+
+ public static readonly SqlString Null = new SqlString (null);
+
+ #endregion // Fields
#region Constructors
// init with a string data
- [MonoTODO]
- public SqlString(string data) {
+ public SqlString (string data)
+ {
+ this.value = data;
}
- // init with a string data and locale id values.\r
- [MonoTODO]\r
- public SqlString(string data, int lcid) {
+ // init with a string data and locale id values.
+ [MonoTODO]
+ public SqlString (string data, int lcid)
+ {
+ throw new NotImplementedException ();
}
// init with locale id, compare options,
// and an array of bytes data
[MonoTODO]
- public SqlString(int lcid, SqlCompareOptions compareOptions,\r
- byte[] data) {
+ public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data)
+ {
+ throw new NotImplementedException ();
}
// init with string data, locale id, and compare options
[MonoTODO]
- public SqlString(string data, int lcid, \r
- SqlCompareOptions compareOptions) {
+ public SqlString (string data, int lcid, SqlCompareOptions compareOptions)
+ {
+ throw new NotImplementedException ();
}
// init with locale id, compare options, array of bytes data,
// and whether unicode is encoded or not
[MonoTODO]
- public SqlString(int lcid, SqlCompareOptions compareOptions,\r
- byte[] data, bool fUnicode) {
+ public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, bool fUnicode)
+ {
+ throw new NotImplementedException ();
}
// init with locale id, compare options, array of bytes data,
// starting index in the byte array,
// and number of bytes to copy
[MonoTODO]
- public SqlString(int lcid, SqlCompareOptions compareOptions,\r
- byte[] data, int index, int count) {
+ public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, int index, int count)
+ {
+ throw new NotImplementedException ();
}
// init with locale id, compare options, array of bytes data,
// starting index in the byte array, number of byte to copy,
// and whether unicode is encoded or not
[MonoTODO]
- public SqlString(int lcid, SqlCompareOptions compareOptions,\r
- byte[] data, int index, int count, bool fUnicode) {
+ public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, int index, int count, bool fUnicode)
+ {
+ throw new NotImplementedException ();
}
#endregion // Constructors
- #region Public Fields
-
- public static readonly int BinarySort;
-
- public static readonly int IgnoreCase;
-
- public static readonly int IgnoreKanaType;
-
- public static readonly int IgnoreNonSpace;
-
- public static readonly int IgnoreWidth;
-
- public static readonly SqlString Null;
-
- #endregion // Fields
#region Public Properties
public CompareInfo CompareInfo {
[MonoTODO]
- get {
+ get { throw new NotImplementedException ();
}
}
public CultureInfo CultureInfo {
[MonoTODO]
- get {
+ get { throw new NotImplementedException ();
}
}
public bool IsNull {
- [MonoTODO]
- get {
- }
+ get { return (value == null); }
}
// geographics location and language (locale id)
public int LCID {
[MonoTODO]
- get {
+ get { throw new NotImplementedException ();
}
}
public SqlCompareOptions SqlCompareOptions {
[MonoTODO]
- get {
+ get { throw new NotImplementedException ();
}
}
public string Value {
- [MonoTODO]
- get {
- }
+ get { return value; }
}
#endregion // Public Properties
#region Public Methods
[MonoTODO]
- public SqlString Clone() {
+ public SqlString Clone()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public static CompareOptions \r
- CompareOptionsFromSqlCompareOptions (\r
- SqlCompareOptions compareOptions) {
+ public static CompareOptions CompareOptionsFromSqlCompareOptions ( SqlCompareOptions compareOptions)
+ {
+ throw new NotImplementedException ();
}
// **********************************
// **********************************
[MonoTODO]
- public int CompareTo(object value){
+ public int CompareTo(object value)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlString Concat(SqlString x, SqlString y) {
+ public static SqlString Concat(SqlString x, SqlString y)
+ {
+ return (x + y);
}
[MonoTODO]
- public override bool Equals(object value) {
+ public override bool Equals(object value)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBoolean Equals(SqlString x, SqlString y) {
+ public static SqlBoolean Equals(SqlString x, SqlString y)
+ {
+ return (x == y);
}
[MonoTODO]
- public override int GetHashCode() {
+ public override int GetHashCode()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public byte[] GetNonUnicodeBytes() {
+ public byte[] GetNonUnicodeBytes()
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBoolean GreaterThan(SqlString x,
- SqlString y) {
+ public static SqlBoolean GreaterThan(SqlString x, SqlString y)
+ {
+ return (x > y);
}
- [MonoTODO]
- public static SqlBoolean GreaterThanOrEqual(SqlString x,\r
- SqlString y) {
+ public static SqlBoolean GreaterThanOrEqual(SqlString x, SqlString y)
+ {
+ return (x >= y);
}
- [MonoTODO]
- public static SqlBoolean LessThan(SqlString x, SqlString y) {
+ public static SqlBoolean LessThan(SqlString x, SqlString y)
+ {
+ return (x < y);
}
- [MonoTODO]
- public static SqlBoolean LessThanOrEqual(SqlString x,\r
- SqlString y) {
+ public static SqlBoolean LessThanOrEqual(SqlString x, SqlString y)
+ {
+ return (x <= y);
}
- [MonoTODO]
- public static SqlBoolean NotEquals(SqlString x, SqlString y) {\r
+ public static SqlBoolean NotEquals(SqlString x, SqlString y)
+ {
+ return (x != y);
}
// ****************************************
// ****************************************
[MonoTODO]
- public SqlBoolean ToSqlBoolean() {
+ public SqlBoolean ToSqlBoolean()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlByte ToSqlByte() {
+ public SqlByte ToSqlByte()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlDateTime ToSqlDateTime() {
+ public SqlDateTime ToSqlDateTime()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlDecimal ToSqlDecimal() {
+ public SqlDecimal ToSqlDecimal()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlDouble ToSqlDouble() {
+ public SqlDouble ToSqlDouble()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlGuid ToSqlGuid() {
+ public SqlGuid ToSqlGuid()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlInt16 ToSqlInt16() {
+ public SqlInt16 ToSqlInt16()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlInt32 ToSqlInt32() {
+ public SqlInt32 ToSqlInt32()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlInt64 ToSqlInt64() {
+ public SqlInt64 ToSqlInt64()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlMoney ToSqlMoney() {
+ public SqlMoney ToSqlMoney()
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public SqlSingle ToSqlSingle() {
+ public SqlSingle ToSqlSingle()
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public override string ToString() {
+ public override string ToString()
+ {
+ return value;
}
// ***********************************
// ***********************************
// Concatenates
- [MonoTODO]
- public static SqlString operator +(SqlString x, SqlString y) {
+ public static SqlString operator + (SqlString x, SqlString y)
+ {
+ return new SqlString (x.Value + y.Value);
}
// Equality
- [MonoTODO]
- public static SqlBoolean operator ==(SqlString x,
- SqlString y) {
+ public static SqlBoolean operator == (SqlString x, SqlString y)
+ {
+ return new SqlBoolean (x.Value == y.Value);
}
[MonoTODO]
- public static SqlBoolean operator >(SqlString x,\r
- SqlString y) {
+ public static SqlBoolean operator > (SqlString x, SqlString y)
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator >=(SqlString x,\r
- SqlString y) {
+ public static SqlBoolean operator >= (SqlString x, SqlString y)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static SqlBoolean operator !=(SqlString x,\r
- SqlString y) {
+ public static SqlBoolean operator != (SqlString x, SqlString y)
+ {
+ return new SqlBoolean (x.Value != y.Value);
}
[MonoTODO]
- public static SqlBoolean operator <(SqlString x,\r
- SqlString y) {
+ public static SqlBoolean operator < (SqlString x, SqlString y)
+ {
+ throw new NotImplementedException ();
}
[MonoTODO]
- public static SqlBoolean operator <=(SqlString x,\r
- SqlString y) {
+ public static SqlBoolean operator <= (SqlString x, SqlString y)
+ {
+ throw new NotImplementedException ();
}
// **************************************
// Type Conversions
// **************************************
- [MonoTODO]
- public static explicit operator SqlString(SqlBoolean x) {
+ public static explicit operator SqlString (SqlBoolean x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlByte x) {
+ public static explicit operator SqlString (SqlByte x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlDateTime x) {
+ public static explicit operator SqlString (SqlDateTime x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlDecimal x) {
+ public static explicit operator SqlString (SqlDecimal x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlDouble x) {
+ public static explicit operator SqlString (SqlDouble x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlGuid x) {
+ public static explicit operator SqlString (SqlGuid x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlInt16 x) {
+ public static explicit operator SqlString (SqlInt16 x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlInt32 x) {
+ public static explicit operator SqlString (SqlInt32 x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlInt64 x) {
+ public static explicit operator SqlString (SqlInt64 x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlMoney x) {
+ public static explicit operator SqlString (SqlMoney x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator SqlString(SqlSingle x) {
+ public static explicit operator SqlString (SqlSingle x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static explicit operator string(SqlString x) {
+ public static explicit operator string (SqlString x)
+ {
+ throw new NotImplementedException ();
}
- [MonoTODO]
- public static implicit operator SqlString(string x) {
+ public static implicit operator SqlString (string x)
+ {
+ throw new NotImplementedException ();
}
+
+ #endregion // Public Methods
}
}