Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAtsushi Eno <atsushieno@gmail.com>2004-04-12 12:42:40 +0400
committerAtsushi Eno <atsushieno@gmail.com>2004-04-12 12:42:40 +0400
commitdf471d99c80cbada2b413549c6542bf95a0eede8 (patch)
tree666fc7d1d5b828ff2705399f1ea152a6d0d76a32 /mcs/class/System.Data/System.Data.SqlTypes
parent3e770c8919a74bd311e56e57851c694824c11e33 (diff)
2004-04-12 Atsushi Enomoto <atsushi@ximian.com>
* SqlBoolean.cs : Allow "0" and "1" on Parse(). Allow SqlString.Null in conversion. * SqlString.cs : CompareOption should not be None. svn path=/trunk/mcs/; revision=25352
Diffstat (limited to 'mcs/class/System.Data/System.Data.SqlTypes')
-rw-r--r--mcs/class/System.Data/System.Data.SqlTypes/ChangeLog6
-rw-r--r--mcs/class/System.Data/System.Data.SqlTypes/SqlBoolean.cs8
-rw-r--r--mcs/class/System.Data/System.Data.SqlTypes/SqlString.cs43
3 files changed, 51 insertions, 6 deletions
diff --git a/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog b/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
index e45dc67324c..5ac0c669853 100644
--- a/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
+++ b/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
@@ -1,3 +1,9 @@
+2004-04-12 Atsushi Enomoto <atsushi@ximian.com>
+
+ * SqlBoolean.cs : Allow "0" and "1" on Parse(). Allow SqlString.Null
+ in conversion.
+ * SqlString.cs : CompareOption should not be None.
+
2004-04-01 Lluis Sanchez Gual <lluis@ximian.com>
* SqlNullValueException.cs: Use a more clarifying error message.
diff --git a/mcs/class/System.Data/System.Data.SqlTypes/SqlBoolean.cs b/mcs/class/System.Data/System.Data.SqlTypes/SqlBoolean.cs
index b417759bb43..f06d0d96a15 100644
--- a/mcs/class/System.Data/System.Data.SqlTypes/SqlBoolean.cs
+++ b/mcs/class/System.Data/System.Data.SqlTypes/SqlBoolean.cs
@@ -161,6 +161,12 @@ namespace System.Data.SqlTypes
public static SqlBoolean Parse(string s)
{
+ switch (s) {
+ case "0":
+ return new SqlBoolean (false);
+ case "1":
+ return new SqlBoolean (true);
+ }
return new SqlBoolean (Boolean.Parse (s));
}
@@ -414,6 +420,8 @@ namespace System.Data.SqlTypes
public static explicit operator SqlBoolean (SqlString x)
{
checked {
+ if (x.IsNull)
+ return Null;
return SqlBoolean.Parse (x.Value);
}
}
diff --git a/mcs/class/System.Data/System.Data.SqlTypes/SqlString.cs b/mcs/class/System.Data/System.Data.SqlTypes/SqlString.cs
index 08be04356a5..b933ef8128e 100644
--- a/mcs/class/System.Data/System.Data.SqlTypes/SqlString.cs
+++ b/mcs/class/System.Data/System.Data.SqlTypes/SqlString.cs
@@ -41,17 +41,32 @@ namespace System.Data.SqlTypes
public static readonly int IgnoreWidth = 0x10;
public static readonly SqlString Null;
+ internal static readonly NumberFormatInfo MoneyFormat;
+ internal static NumberFormatInfo DecimalFormat;
#endregion // Fields
#region Constructors
+ static SqlString ()
+ {
+ MoneyFormat = (NumberFormatInfo) NumberFormatInfo.InvariantInfo.Clone ();
+ MoneyFormat.NumberDecimalDigits = 4;
+ MoneyFormat.NumberGroupSeparator = String.Empty;
+
+ DecimalFormat = (NumberFormatInfo) NumberFormatInfo.InvariantInfo.Clone ();
+ DecimalFormat.NumberDecimalDigits = 13;
+ DecimalFormat.NumberGroupSeparator = String.Empty;
+ }
+
// init with a string data
public SqlString (string data)
{
this.value = data;
lcid = CultureInfo.CurrentCulture.LCID;
notNull = true;
- this.compareOptions = SqlCompareOptions.None;
+ this.compareOptions = SqlCompareOptions.IgnoreCase |
+ SqlCompareOptions.IgnoreKanaType |
+ SqlCompareOptions.IgnoreWidth;
}
// init with a string data and locale id values.
@@ -60,7 +75,9 @@ namespace System.Data.SqlTypes
this.value = data;
this.lcid = lcid;
notNull = true;
- this.compareOptions = SqlCompareOptions.None;
+ this.compareOptions = SqlCompareOptions.IgnoreCase |
+ SqlCompareOptions.IgnoreKanaType |
+ SqlCompareOptions.IgnoreWidth;
}
// init with locale id, compare options,
@@ -167,6 +184,17 @@ namespace System.Data.SqlTypes
}
}
+ public CompareOptions CompareOptions {
+ get {
+ return
+ (this.compareOptions & SqlCompareOptions.BinarySort) != 0 ?
+ CompareOptions.Ordinal :
+ // 27 == all SqlCompareOptions - BinarySort
+ // (1,2,8,24 are common to CompareOptions)
+ (CompareOptions) ((int) this.compareOptions & 27);
+ }
+ }
+
public bool IsNull {
get { return !notNull; }
}
@@ -225,7 +253,7 @@ namespace System.Data.SqlTypes
// Comparison Methods
// **********************************
- public int CompareTo(object value)
+ public int CompareTo (object value)
{
if (value == null)
return 1;
@@ -233,8 +261,9 @@ namespace System.Data.SqlTypes
throw new ArgumentException (Locale.GetText ("Value is not a System.Data.SqlTypes.SqlString"));
else if (((SqlString)value).IsNull)
return 1;
- else
- return this.value.CompareTo (((SqlString)value).Value);
+// else
+// return String.Compare (this.value, ((SqlString)value).Value, (this.SqlCompareOptions & SqlCompareOptions.IgnoreCase) != 0, this.CultureInfo);
+ return CultureInfo.CompareInfo.Compare (this.value, ((SqlString)value).Value, this.CompareOptions);
}
public static SqlString Concat(SqlString x, SqlString y)
@@ -478,12 +507,13 @@ namespace System.Data.SqlTypes
return new SqlString (x.Value.ToString ());
}
- public static explicit operator SqlString (SqlDecimal x)
+ public static explicit operator SqlString (SqlDecimal x)
{
if (x.IsNull)
return Null;
else
return new SqlString (x.Value.ToString ());
+ return new SqlString (x.Value.ToString ("N", DecimalFormat));
}
public static explicit operator SqlString (SqlDouble x)
@@ -532,6 +562,7 @@ namespace System.Data.SqlTypes
return Null;
else
return new SqlString (x.Value.ToString ());
+ return new SqlString (x.Value.ToString ("N", MoneyFormat));
}
public static explicit operator SqlString (SqlSingle x)