//
using System;
+using System.Xml;
+using System.Xml.Schema;
using System.Globalization;
+using System.Xml.Serialization;
namespace System.Data.SqlTypes
{
+#if NET_2_0
+ [SerializableAttribute]
+ [XmlSchemaProvider ("GetXsdType")]
+#endif
public struct SqlSingle : INullable, IComparable
+#if NET_2_0
+ , IXmlSerializable
+#endif
{
#region Fields
- float value;
-
+ private float value;
private bool notNull;
public static readonly SqlSingle MaxValue = new SqlSingle (3.40282346638528859E+38f);
#region Constructors
- public SqlSingle (double value)
+ public SqlSingle (double value)
{
this.value = (float)value;
notNull = true;
}
- public SqlSingle (float value)
+ public SqlSingle (float value)
{
this.value = value;
notNull = true;
#region Properties
- public bool IsNull {
+ public bool IsNull {
get { return !notNull; }
}
- public float Value {
- get {
- if (this.IsNull)
+ public float Value {
+ get {
+ if (this.IsNull)
throw new SqlNullValueException ();
else
return value;
return CompareSqlSingle ((SqlSingle) value);
}
- #if NET_2_0
+#if NET_2_0
public int CompareTo (SqlSingle value)
{
return CompareSqlSingle (value);
}
- #endif
+#endif
private int CompareSqlSingle (SqlSingle value)
{
{
if (!(value is SqlSingle))
return false;
- else if (this.IsNull && ((SqlSingle)value).IsNull)
- return true;
+ else if (this.IsNull)
+ return ((SqlSingle)value).IsNull;
else if (((SqlSingle)value).IsNull)
return false;
else
public override int GetHashCode ()
{
long LongValue = (long) value;
- return (int)(LongValue ^ (LongValue >> 32));
+ return (int) (LongValue ^ (LongValue >> 32));
}
public static SqlBoolean GreaterThan (SqlSingle x, SqlSingle y)
public SqlBoolean ToSqlBoolean ()
{
- return ((SqlBoolean)this);
+ return ((SqlBoolean) this);
}
public SqlByte ToSqlByte ()
{
- return ((SqlByte)this);
+ return ((SqlByte) this);
}
public SqlDecimal ToSqlDecimal ()
{
- return ((SqlDecimal)this);
+ return ((SqlDecimal) this);
}
public SqlDouble ToSqlDouble ()
{
- return ((SqlDouble)this);
+ return ((SqlDouble) this);
}
public SqlInt16 ToSqlInt16 ()
{
- return ((SqlInt16)this);
+ return ((SqlInt16) this);
}
public SqlInt32 ToSqlInt32 ()
{
- return ((SqlInt32)this);
+ return ((SqlInt32) this);
}
public SqlInt64 ToSqlInt64 ()
{
- return ((SqlInt64)this);
+ return ((SqlInt64) this);
}
public SqlMoney ToSqlMoney ()
{
- return ((SqlMoney)this);
+ return ((SqlMoney) this);
}
-
public SqlString ToSqlString ()
{
- return ((SqlString)this);
+ return ((SqlString) this);
}
public override string ToString ()
public static SqlSingle operator + (SqlSingle x, SqlSingle y)
{
- float f = (float)(x.Value + y.Value);
+ float f = (float) (x.Value + y.Value);
if (Single.IsInfinity (f))
throw new OverflowException ();
public static SqlSingle operator / (SqlSingle x, SqlSingle y)
{
- float f = (float)(x.Value / y.Value);
+ float f = (float) (x.Value / y.Value);
if (Single.IsInfinity (f)) {
-
if (y.Value == 0d)
throw new DivideByZeroException ();
}
public static SqlBoolean operator == (SqlSingle x, SqlSingle y)
{
- if (x.IsNull || y .IsNull) return SqlBoolean.Null;
+ if (x.IsNull || y .IsNull)
+ return SqlBoolean.Null;
return new SqlBoolean (x.Value == y.Value);
}
public static SqlBoolean operator > (SqlSingle x, SqlSingle y)
{
- if (x.IsNull || y .IsNull) return SqlBoolean.Null;
+ if (x.IsNull || y .IsNull)
+ return SqlBoolean.Null;
return new SqlBoolean (x.Value > y.Value);
}
public static SqlBoolean operator >= (SqlSingle x, SqlSingle y)
{
- if (x.IsNull || y .IsNull) return SqlBoolean.Null;
+ if (x.IsNull || y .IsNull)
+ return SqlBoolean.Null;
return new SqlBoolean (x.Value >= y.Value);
}
public static SqlBoolean operator != (SqlSingle x, SqlSingle y)
{
- if (x.IsNull || y .IsNull) return SqlBoolean.Null;
+ if (x.IsNull || y .IsNull)
+ return SqlBoolean.Null;
return new SqlBoolean (!(x.Value == y.Value));
}
public static SqlBoolean operator < (SqlSingle x, SqlSingle y)
{
- if (x.IsNull || y .IsNull) return SqlBoolean.Null;
+ if (x.IsNull || y .IsNull)
+ return SqlBoolean.Null;
return new SqlBoolean (x.Value < y.Value);
}
public static SqlBoolean operator <= (SqlSingle x, SqlSingle y)
{
- if (x.IsNull || y .IsNull) return SqlBoolean.Null;
+ if (x.IsNull || y .IsNull)
+ return SqlBoolean.Null;
return new SqlBoolean (x.Value <= y.Value);
}
public static SqlSingle operator * (SqlSingle x, SqlSingle y)
{
- float f = (float)(x.Value * y.Value);
+ float f = (float) (x.Value * y.Value);
if (Single.IsInfinity (f))
throw new OverflowException ();
public static SqlSingle operator - (SqlSingle x, SqlSingle y)
{
- float f = (float)(x.Value - y.Value);
+ float f = (float) (x.Value - y.Value);
if (Single.IsInfinity (f))
throw new OverflowException ();
return new SqlSingle (f);
}
- public static SqlSingle operator - (SqlSingle n)
+ public static SqlSingle operator - (SqlSingle x)
{
- return new SqlSingle (-(n.Value));
+ return new SqlSingle (-(x.Value));
}
public static explicit operator SqlSingle (SqlBoolean x)
if (Single.IsInfinity (f))
throw new OverflowException ();
-
+
return new SqlSingle(f);
}
public static implicit operator SqlSingle (SqlByte x)
{
- if (x.IsNull)
+ if (x.IsNull)
return Null;
else
- return new SqlSingle((float)x.Value);
+ return new SqlSingle((float) x.Value);
}
public static implicit operator SqlSingle (SqlDecimal x)
{
- if (x.IsNull)
+ if (x.IsNull)
return Null;
else
- return new SqlSingle((float)x.Value);
+ return new SqlSingle((float) x.Value);
}
public static implicit operator SqlSingle (SqlInt16 x)
{
- if (x.IsNull)
+ if (x.IsNull)
return Null;
else
- return new SqlSingle((float)x.Value);
+ return new SqlSingle((float) x.Value);
}
public static implicit operator SqlSingle (SqlInt32 x)
{
- if (x.IsNull)
+ if (x.IsNull)
return Null;
else
- return new SqlSingle((float)x.Value);
+ return new SqlSingle((float) x.Value);
}
public static implicit operator SqlSingle (SqlInt64 x)
{
- if (x.IsNull)
+ if (x.IsNull)
return Null;
else
- return new SqlSingle((float)x.Value);
+ return new SqlSingle((float) x.Value);
}
public static implicit operator SqlSingle (SqlMoney x)
{
- if (x.IsNull)
+ if (x.IsNull)
return Null;
else
- return new SqlSingle((float)x.Value);
+ return new SqlSingle((float) x.Value);
+ }
+
+#if NET_2_0
+ public static XmlQualifiedName GetXsdType (XmlSchemaSet schemaSet)
+ {
+ XmlQualifiedName qualifiedName = new XmlQualifiedName ("float", "http://www.w3.org/2001/XMLSchema");
+ return qualifiedName;
+ }
+
+ [MonoTODO]
+ XmlSchema IXmlSerializable.GetSchema ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ void IXmlSerializable.ReadXml (XmlReader reader)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ void IXmlSerializable.WriteXml (XmlWriter writer)
+ {
+ throw new NotImplementedException ();
}
+#endif
#endregion
}
}
-