Update of /cvsroot/nhibernate/NHibernateContrib/src/Nullables.NHibernate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21720/src/Nullables.NHibernate Added Files: .cvsignore AssemblyInfo.cs NullableBooleanType.cs NullableByteType.cs NullableDateTimeType.cs NullableDecimalType.cs NullableDoubleType.cs NullableGuidType.cs NullableInt16Type.cs NullableInt32Type.cs NullableInt64Type.cs Nullables.NHibernate-1.1.csproj Nullables.NHibernate.build NullableSingleType.cs NullablesTypes.cs NullableTypesType.cs Log Message: NH-15: created a NHibernateContrib folder in cvs --- NEW FILE: NullableInt64Type.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableInt64Type : NullableTypesType { public NullableInt64Type() : base(new Int64SqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableInt64 xTyped = (NullableInt64)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableInt64.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableInt64"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableInt64); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableInt64 has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableInt64.Default; } else { return new NullableInt64((Int64)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableInt64 has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableInt64.Default; } else { return new NullableInt64((Int64)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableInt64 nullableValue = (NullableInt64)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: NullableByteType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableByteType : NullableTypesType { public NullableByteType() : base(new ByteSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableByte xTyped = (NullableByte)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableByte.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableByte"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableByte); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableByte has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableByte.Default; } else { return new NullableByte((Byte)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableByte has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableByte.Default; } else { return new NullableByte((Byte)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableByte nullableValue = (NullableByte)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: NullableTypesType.cs --- using System; using NHibernate; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { /// <summary> /// Abstract type used for implementing types from the NullableTypes library. /// </summary> public abstract class NullableTypesType : NullableType { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( typeof(NullableTypesType) ); public NullableTypesType(SqlType type) : base(type) { } public override object NullSafeGet(System.Data.IDataReader rs, string name) { int index = rs.GetOrdinal(name); if( rs.IsDBNull(index) ) { if ( log.IsDebugEnabled ) { log.Debug("returning null as column: " + name); } return NullValue; //this value is determined by the subclass. } else { object val = null; try { val = Get(rs, index); } catch(System.InvalidCastException ice) { throw new ADOException( "Could not cast the value in field " + name + " to the Type " + this.GetType().Name + ". Please check to make sure that the mapping is correct and that your DataProvider supports this Data Type.", ice); } if ( log.IsDebugEnabled ) { log.Debug("returning '" + ToXML(val) + "' as column: " + name); } return val; } } public abstract object NullValue{ get; } } } --- NEW FILE: NullableDoubleType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableDoubleType : NullableTypesType { public NullableDoubleType() : base(new DoubleSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableDouble xTyped = (NullableDouble)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableDouble.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableDouble"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableDouble); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableDouble has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableDouble.Default; } else { return new NullableDouble((Double)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableDouble has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableDouble.Default; } else { return new NullableDouble((Double)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableDouble nullableValue = (NullableDouble)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: NullableInt32Type.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableInt32Type : NullableTypesType { public NullableInt32Type() : base(new Int32SqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableInt32 xTyped = (NullableInt32)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableInt32.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableInt32"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableInt32); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableInt32 has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableInt32.Default; } else { return new NullableInt32((Int32)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableInt32 has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableInt32.Default; } else { return new NullableInt32((Int32)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableInt32 nullableValue = (NullableInt32)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: NullableDecimalType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableDecimalType : NullableTypesType { public NullableDecimalType() : base(new DecimalSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableDecimal xTyped = (NullableDecimal)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableDecimal.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableDecimal"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableDecimal); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableDecimal has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableDecimal.Default; } else { return new NullableDecimal((Decimal)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableDecimal has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableDecimal.Default; } else { return new NullableDecimal((Decimal)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableDecimal nullableValue = (NullableDecimal)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: NullableInt16Type.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableInt16Type : NullableTypesType { public NullableInt16Type() : base(new Int16SqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableInt16 xTyped = (NullableInt16)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableInt16.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableInt16"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableInt16); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableInt16 has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableInt16.Default; } else { return new NullableInt16((Int16)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableInt16 has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableInt16.Default; } else { return new NullableInt16((Int16)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableInt16 nullableValue = (NullableInt16)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: NullableDateTimeType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableDateTimeType : NullableTypesType { public NullableDateTimeType() : base(new DateTimeSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableDateTime xTyped = (NullableDateTime)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableDateTime.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableDateTime"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableDateTime); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableDateTime has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableDateTime.Default; } else { return new NullableDateTime((DateTime)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableDateTime has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableDateTime.Default; } else { return new NullableDateTime((DateTime)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableDateTime nullableValue = (NullableDateTime)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: NullableSingleType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableSingleType : NullableTypesType { public NullableSingleType() : base(new SingleSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableSingle xTyped = (NullableSingle)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableSingle.Default; } } public override bool HasNiceEquals { get { //the results from .Equals on NullalbeTypes don't suite our use of them (we want 2 nulls to be equal) return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableSingle"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableSingle); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableSingle has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableSingle.Default; } else { return new NullableSingle((Single)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableSingle has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableSingle.Default; } else { return new NullableSingle((Single)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableSingle nullableValue = (NullableSingle)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: Nullables.NHibernate-1.1.csproj --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{35F82297-CAB4-4D57-AAB9-CBDB1F6B8841}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "Nullables.NHibernate" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" PreBuildEvent = "" PostBuildEvent = "" RootNamespace = "Nullables.NHibernate" RunPostBuildEvent = "OnBuildSuccess" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /> <Reference Name = "System.Data" AssemblyName = "System.Data" HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" /> <Reference Name = "System.XML" AssemblyName = "System.Xml" HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> <Reference Name = "Nullables" Project = "{9DEFA2EA-4A52-445A-8DA4-6531BD5D76B5}" Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" /> <Reference Name = "log4net" AssemblyName = "log4net" HintPath = "..\..\lib\net\1.1\log4net.dll" /> <Reference Name = "NHibernate" AssemblyName = "NHibernate" HintPath = "..\..\lib\net\1.1\NHibernate.dll" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableBooleanType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableByteType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableDateTimeType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableDecimalType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableDoubleType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableGuidType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableInt16Type.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableInt32Type.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableInt64Type.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Nullables.NHibernate.build" BuildAction = "None" /> <File RelPath = "NullableSingleType.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullablesTypes.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "NullableTypesType.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE: NullablesTypes.cs --- using System; using NHibernate.Type; namespace Nullables.NHibernate { /// <summary> /// Summary description for NullablesTypes. /// </summary> public sealed class NullablesTypes { /// <summary> /// Nullables.NHibernate.NullableBoolean type /// </summary> public static readonly NullableType NullableBoolean = new NullableBooleanType(); /// <summary> /// Nullables.NHibernate.NullableByte type /// </summary> public static readonly NullableType NullableByte = new NullableByteType(); /// <summary> /// Nullables.NHibernate.NullableDouble type /// </summary> public static readonly NullableType NullableDouble = new NullableDoubleType(); /// <summary> /// Nullables.NHibernate.NullableInt16 type /// </summary> public static readonly NullableType NullableInt16 = new NullableInt16Type(); /// <summary> /// Nullables.NHibernate.NullableInt32 type /// </summary> public static readonly NullableType NullableInt32 = new NullableInt32Type(); /// <summary> /// Nullables.NHibernate.NullableInt64 type /// </summary> public static readonly NullableType NullableInt64 = new NullableInt64Type(); /// <summary> /// Nullables.NHibernate.NullableDecimal type /// </summary> public static readonly NullableType NullableDecimal = new NullableDecimalType(); /// <summary> /// Nullables.NHibernate.NullableDateTime type /// </summary> public static readonly NullableType NullableDateTime = new NullableDateTimeType(); /// <summary> /// Nullables.NHibernate.NullableSingle type /// </summary> public static readonly NullableType NullableSingle = new NullableSingleType(); /// <summary> /// Nullables.NHibernate.NullableGuid type /// </summary> public static readonly NullableType NullableGuid = new NullableGuidType(); } } --- NEW FILE: Nullables.NHibernate.build --- (This appears to be a binary file; contents omitted.) --- NEW FILE: AssemblyInfo.cs --- using System.Reflection; using System.Runtime.CompilerServices; //------------------------------------------------------------------------------ // <autogenerated> // This code was generated by a tool. // Runtime Version: 1.1.4322.573 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </autogenerated> //------------------------------------------------------------------------------ [assembly: AssemblyTitleAttribute("Nullables.NHibernate for Microsoft .NET Framework 1.1")] [assembly: AssemblyDescriptionAttribute("The NHibernate Types for the Nullables.")] [assembly: AssemblyCompanyAttribute("nhibernate.sourceforge.net")] [assembly: AssemblyProductAttribute("Nullables.NHibernate")] [assembly: AssemblyCopyrightAttribute("Licensed under LGPL.")] [assembly: AssemblyVersionAttribute("0.4.0.0")] [assembly: AssemblyInformationalVersionAttribute("0.4")] [assembly: AssemblyFileVersionAttribute("0.4.0.0")] [assembly: AssemblyDelaySignAttribute(false)] --- NEW FILE: NullableBooleanType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableBooleanType : NullableTypesType { public NullableBooleanType() : base(new BooleanSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableBoolean xTyped = (NullableBoolean)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableBoolean.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableBoolean"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableBoolean); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableBoolean has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableBoolean.Default; } else { return new NullableBoolean((Boolean)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableBoolean has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableBoolean.Default; } else { return new NullableBoolean((Boolean)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableBoolean nullableValue = (NullableBoolean)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } --- NEW FILE: .cvsignore --- bin obj .#* *.user *.xsx --- NEW FILE: NullableGuidType.cs --- using System; using NHibernate.Type; using NHibernate.SqlTypes; using Nullables; namespace Nullables.NHibernate { public class NullableGuidType : NullableTypesType { public NullableGuidType() : base(new GuidSqlType()) { } public override bool Equals(object x, object y) { //get boxed values. NullableGuid xTyped = (NullableGuid)x; return xTyped.Equals(y); } public override object NullValue { get { return NullableGuid.Default; } } public override bool HasNiceEquals { get { return true; } } public override bool IsMutable { get { return true; } } public override string Name { get { return "NullableGuid"; } } public override System.Type ReturnedClass { get { return typeof(Nullables.NullableGuid); } } public override object DeepCopyNotNull(object val) { return val; } public override object Get(System.Data.IDataReader rs, int index) { //TODO: perhaps NullableGuid has a method/operator/contructor that will take an object. object value = rs[index]; if( value==DBNull.Value ) { return NullableGuid.Default; } else { return new NullableGuid((Guid)value); } } public override object Get(System.Data.IDataReader rs, string name) { //TODO: perhaps NullableGuid has a method/operator/contructor that will take an object. object value = rs[name]; if( value==DBNull.Value ) { return NullableGuid.Default; } else { return new NullableGuid((Guid)value); } } public override void Set(System.Data.IDbCommand cmd, object value, int index) { System.Data.IDataParameter parameter = (System.Data.IDataParameter)cmd.Parameters[index]; NullableGuid nullableValue = (NullableGuid)value; if( nullableValue.HasValue ) { parameter.Value = nullableValue.Value; } else { parameter.Value = DBNull.Value; } } public override string ToXML(object val) { return val.ToString(); } } } |