NullableTypes/src/Types DbNullConvert.cs,1.3,1.4 NullConvert.cs,1.5,1.6 NullableGuid.cs,1.3,1.4 Type
Status: Inactive
Brought to you by:
lukadotnet
From: \(luKa\) <luk...@us...> - 2005-02-12 03:44:44
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24056/src/Types Modified Files: DbNullConvert.cs NullConvert.cs NullableGuid.cs Types.csproj Log Message: Index: DbNullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/DbNullConvert.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DbNullConvert.cs 7 Oct 2003 20:32:22 -0000 1.3 --- DbNullConvert.cs 12 Feb 2005 03:44:34 -0000 1.4 *************** *** 3,6 **** --- 3,7 ---- // // Authors: Luca Minudel (luk...@us...) + // Damien Guard (dam...@us...) // // Date Author Changes Reasons *************** *** 13,20 **** // NullableTypes.HelperFunctions // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // ! namespace NullableTypes.HelperFunctions ! { using sys = System; using sysGlb = System.Globalization; --- 14,21 ---- // NullableTypes.HelperFunctions // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces + // 28-Jan-2005 DamienG Upgrade Added support for NullableGuid and added regions. // ! namespace NullableTypes.HelperFunctions { using sys = System; using sysGlb = System.Globalization; *************** *** 25,32 **** /// and vice versa. /// </summary> ! public sealed class DBNullConvert ! { private DBNullConvert() {} /// <summary> /// Converts an object value that is DBNull or System.Boolean to an --- 26,33 ---- /// and vice versa. /// </summary> ! public sealed class DBNullConvert { private DBNullConvert() {} + #region To converters /// <summary> /// Converts an object value that is DBNull or System.Boolean to an *************** *** 37,41 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 38,42 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 63,70 **** throw new sys.InvalidCastException( string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText( ! "Value is not a {0} neither a DBNull Value."), "System.Boolean")); } - /// <summary> /// Converts an object value that is DBNull or System.Byte to an --- 64,70 ---- throw new sys.InvalidCastException( string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText( ! "Value is not a {0} neither a DBNull Value."), "System.Boolean")); } /// <summary> /// Converts an object value that is DBNull or System.Byte to an *************** *** 75,79 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 75,79 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 104,107 **** --- 104,143 ---- } + /// <summary> + /// Converts an object value that is DBNull or System.Guid to an + /// equivalent NullableGuid value. + /// </summary> + /// <param name="x"> + /// A value of <see cref="System.Guid"/> type from either a + /// <see cref="System.Data.DataRow"/> Item value, a + /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a + /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. + /// </param> + /// <returns> + /// <see cref="NullableGuid.Null"/> if <paramref name="x"/> is + /// <see cref="System.DBNull"/> otherwise a + /// <see cref="NullableGuid"/> constructed from <paramref name="x"/>. + /// </returns> + /// <exception cref="System.ArgumentNullException"> + /// <paramref name="x"/> is null. + /// </exception> + /// <exception cref="System.InvalidCastException"> + /// <paramref name="x"/> is neither DBNull or of type + /// <see cref="System.Guid"/>. + /// </exception> + public static NullableGuid ToNullableGuid(object x) { + if (x == sys.DBNull.Value) + return NullableGuid.Null; + + if (x is sys.Guid) + return new NullableGuid((sys.Guid)x); + + if (x == null) + throw new sys.ArgumentNullException("x"); + + throw new sys.InvalidCastException( + string.Format(sysGlb.CultureInfo.CurrentCulture, Locale.GetText( + "Value is not a {0} neither a DBNull Value."), "System.Guid")); + } /// <summary> *************** *** 113,117 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 149,153 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 142,146 **** } - /// <summary> /// Converts an object value that is DBNull or System.Int32 to an --- 178,181 ---- *************** *** 151,155 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 186,190 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 180,184 **** } - /// <summary> /// Converts an object value that is DBNull or System.Int64 to an --- 215,218 ---- *************** *** 189,193 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 223,227 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 218,222 **** } - /// <summary> /// Converts an object value that is DBNull or System.Single to an --- 252,255 ---- *************** *** 227,231 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 260,264 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 256,260 **** } - /// <summary> /// Converts an object value that is DBNull or System.Double to an --- 289,292 ---- *************** *** 265,269 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 297,301 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 294,298 **** } - /// <summary> /// Converts an object value that is DBNull or System.DateTime to an --- 326,329 ---- *************** *** 303,307 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 334,338 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 332,336 **** } - /// <summary> /// Converts an object value that is DBNull or System.Decimal to an --- 363,366 ---- *************** *** 341,345 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 371,375 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 370,374 **** } - /// <summary> /// Converts an object value that is DBNull or System.String to an --- 400,403 ---- *************** *** 379,383 **** /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value. /// </param> /// <returns> --- 408,412 ---- /// <see cref="System.Data.DataRow"/> Item value, a /// <see cref="System.Data.IDbCommand.Parameters"/> Item value or a ! /// <see cref="System.Data.IDataRecord"/> GetValue returned value.. /// </param> /// <returns> *************** *** 407,412 **** "Value is not a {0} neither a DBNull Value."), "System.String")); } ! /// <summary> /// Converts the specified value to an --- 436,442 ---- "Value is not a {0} neither a DBNull Value."), "System.String")); } + #endregion // To converters ! #region From converters /// <summary> /// Converts the specified value to an *************** *** 431,435 **** } - /// <summary> /// Converts the specified value to an --- 461,464 ---- *************** *** 454,458 **** } - /// <summary> /// Converts the specified value to an --- 483,486 ---- *************** *** 477,481 **** } - /// <summary> /// Converts the specified value to an --- 505,508 ---- *************** *** 500,504 **** } - /// <summary> /// Converts the specified value to an --- 527,530 ---- *************** *** 523,527 **** } - /// <summary> /// Converts the specified value to an --- 549,552 ---- *************** *** 546,550 **** } - /// <summary> /// Converts the specified value to an --- 571,574 ---- *************** *** 569,573 **** } - /// <summary> /// Converts the specified value to an --- 593,596 ---- *************** *** 592,596 **** } - /// <summary> /// Converts the specified value to an --- 615,618 ---- *************** *** 615,619 **** } - /// <summary> /// Converts the specified value to an --- 637,640 ---- *************** *** 637,640 **** return x.Value; } } ! } --- 658,662 ---- return x.Value; } + #endregion // From converters } ! } \ No newline at end of file Index: NullableGuid.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullableGuid.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** NullableGuid.cs 27 Jun 2003 15:33:30 -0000 1.3 --- NullableGuid.cs 12 Feb 2005 03:44:34 -0000 1.4 *************** *** 1,18 **** // ! // NullableTypes.? // // Authors: Luca Minudel (luk...@us...) ! // ... // // Date Author Changes Reasons // 07-Apr-2003 Luca Created Declared public members ! // ??-Apr-2003 ... ... // namespace NullableTypes { using sys = System; ! public struct NullableGuid : INullable, sys.IComparable ! { #region Fields sys.Guid _value; --- 1,22 ---- // ! // NullableTypes.NullableGuid // // Authors: Luca Minudel (luk...@us...) ! // Damien Guard (dam...@us...) // // Date Author Changes Reasons // 07-Apr-2003 Luca Created Declared public members ! // 28-Jan-2005 DamienG Completed Removed NullableBinary code, fixed ToNullableString, added missing constructor, ! // Added IXmlSerializable support // namespace NullableTypes { using sys = System; + using sysXml = System.Xml; + using sysXmlSrl = System.Xml.Serialization; + using sysXmlScm = System.Xml.Schema; ! [sys.Serializable] ! public struct NullableGuid : INullable, sys.IComparable, sysXmlSrl.IXmlSerializable { #region Fields sys.Guid _value; *************** *** 38,41 **** --- 42,50 ---- } + public NullableGuid(int a, short b, short c, byte[] d) { + _value = new sys.Guid(a, b, c, d); + _notNull = true; + } + public NullableGuid (int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) { _value = new sys.Guid (a, b, c, d, e, f, g, h, i, j, k); *************** *** 81,85 **** } - public static NullableBoolean operator == (NullableGuid x, NullableGuid y) { if (x.IsNull || y.IsNull) return NullableBoolean.Null; --- 90,93 ---- *************** *** 97,111 **** public override int GetHashCode() { ! byte [] bytes = this.ToByteArray (); ! ! int result = 10; ! foreach (byte b in bytes) { ! result = 91 * result + b.GetHashCode (); ! } ! return result; } ! #endregion // Equivalence #region Properties --- 105,174 ---- public override int GetHashCode() { ! return _value.GetHashCode(); ! } ! #endregion // Equivalence ! #region IXmlSerializable ! /// <summary> ! /// This member supports the .NET Framework infrastructure and is not intended to be used directly ! /// from your code. ! /// </summary> ! [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] ! sysXml.Schema.XmlSchema sysXmlSrl.IXmlSerializable.GetSchema() { ! // <?xml version="1.0"?> ! // <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" ! // targetNamespace="http://NullableTypes.SourceForge.Net/NullableGuidXMLSchema" ! // xmlns="http://NullableTypes.SourceForge.Net/NullableGuidXMLSchema" ! // elementFormDefault="qualified"> ! // <xs:element name="NullableGuid" type="xs:hexBinary" nillable="true" /> ! // </xs:schema> ! ! // Element: NullableGuid ! sysXmlScm.XmlSchemaElement rootElement = new sysXmlScm.XmlSchemaElement(); ! rootElement.Name = "NullableGuid"; ! rootElement.SchemaTypeName = ! new sysXml.XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); ! rootElement.IsNillable = true; ! ! // Xml Schema ! sysXmlScm.XmlSchema xsd = new sysXmlScm.XmlSchema(); ! xsd.Id = "NullableGuid"; ! xsd.Namespaces.Add("xs", "http://www.w3.org/2001/XMLSchema"); ! xsd.TargetNamespace = "http://NullableTypes.SourceForge.Net/NullableGuidXMLSchema"; ! xsd.Items.Add(rootElement); ! xsd.ElementFormDefault = sysXmlScm.XmlSchemaForm.Qualified; ! ! return xsd; } ! /// <summary> ! /// This member supports the .NET Framework infrastructure and is not intended to be used directly ! /// from your code. ! /// </summary> ! [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] ! void sysXmlSrl.IXmlSerializable.WriteXml(sysXml.XmlWriter writer) { ! if (!IsNull) ! writer.WriteString(sysXml.XmlConvert.ToString(_value)); ! else ! writer.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true"); ! } ! ! /// <summary> ! /// This member supports the .NET Framework infrastructure and is not intended to be used directly ! /// from your code. ! /// </summary> ! [sys.ComponentModel.EditorBrowsable(sys.ComponentModel.EditorBrowsableState.Never)] ! void sysXmlSrl.IXmlSerializable.ReadXml(sysXml.XmlReader reader) { ! string nilValue = reader["nil", "http://www.w3.org/2001/XMLSchema-instance"]; ! string elementValue = reader.IsEmptyElement ? null : reader.ReadElementString(); ! ! if (nilValue == null || nilValue == "false" || nilValue == "0") { ! _value = sysXml.XmlConvert.ToGuid(elementValue); ! _notNull = true; ! } ! else ! _notNull = false; ! } ! #endregion // IXmlSerializable #region Properties *************** *** 156,165 **** if (x.IsNull || y.IsNull) return NullableBoolean.Null; ! if (x.Value.CompareTo (y.Value) >= 0) return new NullableBoolean (true); else return new NullableBoolean (false); - } --- 219,227 ---- if (x.IsNull || y.IsNull) return NullableBoolean.Null; ! if (x.Value.CompareTo (y.Value) >= 0) return new NullableBoolean (true); else return new NullableBoolean (false); } *************** *** 172,176 **** else return new NullableBoolean (false); - } --- 234,237 ---- *************** *** 187,194 **** #region Conversion Operators - public static explicit operator NullableGuid(NullableBinary x) { - return new NullableGuid (x.Value); - } - public static explicit operator sys.Guid(NullableGuid x) { return x.Value; --- 248,251 ---- *************** *** 211,220 **** } - public NullableBinary ToNullableBinary () { - return ((NullableBinary)this); - } - public NullableString ToNullableString () { ! return ((NullableString)this); } --- 268,276 ---- } public NullableString ToNullableString () { ! if (this.IsNull) ! return NullableString.Null; ! else ! return new NullableString(_value.ToString()); } *************** *** 226,231 **** } #endregion // Conversions ! ! } } - --- 282,285 ---- } #endregion // Conversions ! } } Index: Types.csproj =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/Types.csproj,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Types.csproj 8 Dec 2003 21:57:27 -0000 1.17 --- Types.csproj 12 Feb 2005 03:44:34 -0000 1.18 *************** *** 72,82 **** <Reference Name = "System.XML" ! AssemblyName = "System.Xml" ! HintPath = "D:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll" ! /> ! <Reference ! Name = "System.Data" ! AssemblyName = "System.Data" ! HintPath = "D:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll" /> </References> --- 72,77 ---- <Reference Name = "System.XML" ! AssemblyName = "System.XML" ! HintPath = "H:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> </References> *************** *** 120,123 **** --- 115,123 ---- /> <File + RelPath = "NullableGuid.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "NullableInt16.cs" SubType = "Code" Index: NullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullConvert.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** NullConvert.cs 7 Oct 2003 20:32:22 -0000 1.5 --- NullConvert.cs 12 Feb 2005 03:44:34 -0000 1.6 *************** *** 3,6 **** --- 3,7 ---- // // Authors: Luca Minudel (luk...@us...) + // Damien Guard (dam...@us...) // // Date Author Changes Reasons *************** *** 10,17 **** // and with a specified format. // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces // ! namespace NullableTypes.HelperFunctions ! { using sys = System; using sysGlb = System.Globalization; --- 11,18 ---- // and with a specified format. // 06-Oct-2003 Luca Upgrade Code upgrade: Replaced tabs with spaces + // 28-Jan-2005 DamienG Upgrade Added helpers for NullableGuid and added regions. // ! namespace NullableTypes.HelperFunctions { using sys = System; using sysGlb = System.Globalization; *************** *** 19,29 **** /// <summary> /// Converts non nullable .NET built-in types to and from NullableTypes using conventional values to ! /// simulate null values. Can be used to seamlessly integrate NullableTypes with Web server controls ! /// and WinForms controls. /// </summary> public sealed class NullConvert { private NullConvert() {} ! /// <summary> /// Converts the specified <see cref="NullableBoolean"/> value to an equivalent --- 20,29 ---- /// <summary> /// Converts non nullable .NET built-in types to and from NullableTypes using conventional values to ! /// simulate null values. Can be used to seamlessly integrate NullableTypes with WebForms and WinForms controls. /// </summary> public sealed class NullConvert { private NullConvert() {} ! #region From converters /// <summary> /// Converts the specified <see cref="NullableBoolean"/> value to an equivalent *************** *** 49,53 **** } - /// <summary> /// Converts the specified <see cref="NullableBoolean"/> value to an equivalent --- 49,52 ---- *************** *** 64,68 **** /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is /// <see cref="NullableBoolean.Null"/> otherwise the string representation of the ! /// <see cref="NullableBoolean.Value"/> of <paramref name="x"/>. /// </returns> public static string From(NullableBoolean x, string conventionalNullValue) { --- 63,67 ---- /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is /// <see cref="NullableBoolean.Null"/> otherwise the string representation of the ! /// <see cref="NullableBoolean.Value"/> of <paramref name="x"/>.. /// </returns> public static string From(NullableBoolean x, string conventionalNullValue) { *************** *** 73,77 **** } - /// <summary> /// Converts the specified <see cref="NullableByte"/> value to an equivalent --- 72,75 ---- *************** *** 97,101 **** } - /// <summary> /// Converts the specified <see cref="NullableByte"/> value to an equivalent --- 95,98 ---- *************** *** 139,142 **** --- 136,202 ---- } + /// <summary> + /// Converts the specified <see cref="NullableGuid"/> value to an equivalent + /// <see cref="System.Byte"/> value using a conventional <see cref="System.Byte"/> value to + /// represent the <see cref="NullableGuid.Null"/> value. + /// </summary> + /// <param name="x"> + /// The <see cref="NullableGuid"/> value to convert. + /// </param> + /// <param name="conventionalNullValue"> + /// The <see cref="System.Guid"/> value that conventionally represent the null value. + /// </param> + /// <returns> + /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is + /// <see cref="NullableGuid.Null"/> otherwise the <see cref="NullableGuid.Value"/> of + /// <paramref name="x"/>. + /// </returns> + public static sys.Guid From(NullableGuid x, sys.Guid conventionalNullValue) { + if (x.IsNull) + return conventionalNullValue; + + return x.Value; + } + + /// <summary> + /// Converts the specified <see cref="NullableGuid"/> value to an equivalent + /// <see cref="System.String"/> value using a conventional <see cref="System.String"/> value to + /// represent the <see cref="NullableGuid.Null"/> value. + /// </summary> + /// <param name="x"> + /// The <see cref="NullableGuid"/> value to convert. + /// </param> + /// <param name="conventionalNullValue"> + /// The <see cref="System.String"/> value that conventionally represent the + /// <see cref="NullableGuid.Null"/> value. + /// </param> + /// <param name="format"> + /// A string that specifies the return format of <paramref name="x"/> if it is not + /// <see cref="NullableGuid.Null"/>. + /// </param> + /// <returns> + /// <paramref name="conventionalNullValue"/> if <paramref name="x"/> is + /// <see cref="NullableGuid.Null"/> otherwise the equivalent string of the + /// <see cref="NullableGuid.Value"/> of <paramref name="x"/> formatted as specified by + /// <paramref name="format"/>. + /// </returns> + /// <exception cref="System.FormatException"> + /// <paramref name="x"/> is not <see cref="NullableGuid.Null"/> and the <paramref name="format"/> + /// is invalid for a Byte. + /// </exception> + /// <remarks> + /// If <paramref name="format"/> is a null reference (Nothing in Visual Basic) or an empty string (""), + /// general format specifier ("G") will be used. + /// <para> + /// The <see cref="System.Globalization.NumberFormatInfo"/> for the current culture is used when + /// applying fomatting. + /// </para> + /// </remarks> + public static string From(NullableGuid x, string conventionalNullValue, string format) { + if (x.IsNull) + return conventionalNullValue; + + return x.Value.ToString(format, sysGlb.CultureInfo.CurrentCulture); + } /// <summary> *************** *** 163,167 **** } - /// <summary> /// Converts the specified <see cref="NullableInt16"/> value to an equivalent --- 223,226 ---- *************** *** 205,209 **** } - /// <summary> /// Converts the specified <see cref="NullableInt32"/> value to an equivalent --- 264,267 ---- *************** *** 229,233 **** } - /// <summary> /// Converts the specified <see cref="NullableInt32"/> value to an equivalent --- 287,290 ---- *************** *** 271,275 **** } - /// <summary> /// Converts the specified <see cref="NullableInt64"/> value to an equivalent --- 328,331 ---- *************** *** 295,299 **** } - /// <summary> /// Converts the specified <see cref="NullableInt64"/> value to an equivalent --- 351,354 ---- *************** *** 337,341 **** } - /// <summary> /// Converts the specified <see cref="NullableSingle"/> value to an equivalent --- 392,395 ---- *************** *** 361,365 **** } - /// <summary> /// Converts the specified <see cref="NullableSingle"/> value to an equivalent --- 415,418 ---- *************** *** 403,407 **** } - /// <summary> /// Converts the specified <see cref="NullableDouble"/> value to an equivalent --- 456,459 ---- *************** *** 427,431 **** } - /// <summary> /// Converts the specified <see cref="NullableDouble"/> value to an equivalent --- 479,482 ---- *************** *** 469,473 **** } - /// <summary> /// Converts the specified <see cref="NullableDecimal"/> value to an equivalent --- 520,523 ---- *************** *** 493,497 **** } - /// <summary> /// Converts the specified <see cref="NullableDecimal"/> value to an equivalent --- 543,546 ---- *************** *** 535,539 **** } - /// <summary> /// Converts the specified <see cref="NullableDateTime"/> value to an equivalent --- 584,587 ---- *************** *** 559,563 **** } - /// <summary> /// Converts the specified <see cref="NullableDateTime"/> value to an equivalent --- 607,610 ---- *************** *** 603,607 **** } - /// <summary> /// Converts the specified <see cref="NullableString"/> value to an equivalent --- 650,653 ---- *************** *** 626,631 **** return x.Value; } ! /// <summary> /// Converts the specified <see cref="System.Boolean"/> value whose null value is simulated using a --- 672,678 ---- return x.Value; } + #endregion // From converters ! #region To converters /// <summary> /// Converts the specified <see cref="System.Boolean"/> value whose null value is simulated using a *************** *** 650,654 **** } - /// <summary> /// Converts the specified <see cref="System.Int32"/> value whose null value is simulated using a --- 697,700 ---- *************** *** 673,677 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a logical value to its --- 719,722 ---- *************** *** 709,713 **** } - /// <summary> /// Converts the specified <see cref="System.Byte"/> value whose null value is simulated using a --- 754,757 ---- *************** *** 733,737 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 777,780 ---- *************** *** 771,774 **** --- 814,839 ---- } + /// <summary> + /// Converts the specified <see cref="System.Guid"/> value whose null value is simulated using a + /// a conventional <see cref="System.Guid"/> value to an equivalent <see cref="NullableGuid"/>. + /// </summary> + /// <param name="x"> + /// The <see cref="System.Guid"/> value to convert. + /// </param> + /// <param name="conventionalNullValue"> + /// The <see cref="System.Guid"/> value that conventionally represent the null value. + /// </param> + /// <returns> + /// <see cref="NullableGuid.Null"/> if <paramref name="x"/> is equals to + /// <paramref name="conventionalNullValue"/> otherwise a <see cref="NullableGuid"/> constructed from + /// <paramref name="x"/>. + /// </returns> + public static NullableGuid ToNullableGuid(sys.Guid x, System.Guid conventionalNullValue) { + if (x == conventionalNullValue) + return NullableGuid.Null; + + return new NullableGuid(x); + + } /// <summary> *************** *** 795,799 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 860,863 ---- *************** *** 833,837 **** } - /// <summary> /// Converts the specified <see cref="System.Int32"/> value whose null value is simulated using a --- 897,900 ---- *************** *** 857,861 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 920,923 ---- *************** *** 895,899 **** } - /// <summary> /// Converts the specified <see cref="System.Int64"/> value whose null value is simulated using a --- 957,960 ---- *************** *** 919,923 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 980,983 ---- *************** *** 957,961 **** } - /// <summary> /// Converts the specified <see cref="System.Single"/> value whose null value is simulated using a --- 1017,1020 ---- *************** *** 987,991 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1046,1049 ---- *************** *** 1029,1033 **** } - /// <summary> /// Converts the specified <see cref="System.Double"/> value whose null value is simulated using a --- 1087,1090 ---- *************** *** 1059,1063 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1116,1119 ---- *************** *** 1101,1105 **** } - /// <summary> /// Converts the specified <see cref="System.Decimal"/> value whose null value is simulated using a --- 1157,1160 ---- *************** *** 1126,1130 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1181,1184 ---- *************** *** 1168,1173 **** } - - /// <summary> /// Converts the specified <see cref="System.DateTime"/> value whose null value is simulated using a --- 1222,1225 ---- *************** *** 1193,1197 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> representation of a number to its --- 1245,1248 ---- *************** *** 1235,1239 **** } - /// <summary> /// Converts the specified <see cref="System.String"/> to its <see cref="NullableString"/> equivalent. --- 1286,1289 ---- *************** *** 1266,1270 **** return new NullableString(x); } ! } ! } \ No newline at end of file --- 1316,1320 ---- return new NullableString(x); } ! #endregion // To converters } ! } |