Thread: NullableTypes/src/Types NullConvert.cs,1.8,1.9
Status: Inactive
Brought to you by:
lukadotnet
From: Damien G. <dam...@us...> - 2005-10-25 11:50:55
|
Update of /cvsroot/nullabletypes/NullableTypes/src/Types In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26930/src/Types Modified Files: NullConvert.cs Log Message: Added formatted NullableGuid converter back in and fixed some more XML docs. Index: NullConvert.cs =================================================================== RCS file: /cvsroot/nullabletypes/NullableTypes/src/Types/NullConvert.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** NullConvert.cs 11 Oct 2005 12:18:52 -0000 1.8 --- NullConvert.cs 25 Oct 2005 11:50:46 -0000 1.9 *************** *** 14,17 **** --- 14,18 ---- // 26-Sep-2005 DamienG Upgrade Added helpers for NullableTimeSpan. // 11-Oct-2005 DamienG Upgrade Remove formated NullableGuid converter and added XML docs for NullableTimeSpan. + // 25-Oct-2005 DamienG Upgrade Added formatted NullableGuid converter back in and fixed some more XML docs. // *************** *** 121,125 **** /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableByte.Null"/> and the <paramref name="format"/> ! /// is invalid for a Byte. /// </exception> /// <remarks> --- 122,126 ---- /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableByte.Null"/> and the <paramref name="format"/> ! /// is invalid for a <see cref="System.Byte" />. /// </exception> /// <remarks> *************** *** 161,164 **** --- 162,197 ---- } + + /// <summary> + /// Converts the specified <see cref="NullableGuid"/> value to an equivalent + /// <see cref="System.Guid"/> value using a conventional <see cref="System.Guid"/> 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> + /// <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 <see cref="NullableGuid.Value"/> of + /// <paramref name="x"/>. + /// </returns> + /// <exception cref="System.FormatException"> + /// <paramref name="x"/> is not <see cref="NullableByte.Null"/> and the <paramref name="format"/> + /// is invalid for a <see cref="System.Guid" />. + /// </exception> + public static string From(NullableGuid x, string conventionalNullValue, string format) { + if (x.IsNull) + return conventionalNullValue; + + return x.Value.ToString(format, sysGlb.CultureInfo.CurrentCulture); + } + /// <summary> /// Converts the specified <see cref="NullableInt16"/> value to an equivalent *************** *** 208,212 **** /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableInt16.Null"/> and the <paramref name="format"/> ! /// is invalid for an Int16. /// </exception> /// <remarks> --- 241,245 ---- /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableInt16.Null"/> and the <paramref name="format"/> ! /// is invalid for an <see cref="System.Int16" />. /// </exception> /// <remarks> *************** *** 272,276 **** /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableInt32.Null"/> and the <paramref name="format"/> ! /// is invalid for an Int32. /// </exception> /// <remarks> --- 305,309 ---- /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableInt32.Null"/> and the <paramref name="format"/> ! /// is invalid for an <see cref="System.Int32"/>. /// </exception> /// <remarks> *************** *** 336,340 **** /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableInt64.Null"/> and the <paramref name="format"/> ! /// is invalid for an Int64. /// </exception> /// <remarks> --- 369,373 ---- /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableInt64.Null"/> and the <paramref name="format"/> ! /// is invalid for an <see cref="System.Int64" />. /// </exception> /// <remarks> *************** *** 400,404 **** /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableSingle.Null"/> and the <paramref name="format"/> ! /// is invalid for a Single. /// </exception> /// <remarks> --- 433,437 ---- /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableSingle.Null"/> and the <paramref name="format"/> ! /// is invalid for a <see cref="System.Single" />. /// </exception> /// <remarks> *************** *** 464,468 **** /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableDouble.Null"/> and the <paramref name="format"/> ! /// is invalid for a Double. /// </exception> /// <remarks> --- 497,501 ---- /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableDouble.Null"/> and the <paramref name="format"/> ! /// is invalid for a <see cref="System.Double" />. /// </exception> /// <remarks> *************** *** 528,532 **** /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableDecimal.Null"/> and the <paramref name="format"/> ! /// is invalid for a Decimal. /// </exception> /// <remarks> --- 561,565 ---- /// <exception cref="System.FormatException"> /// <paramref name="x"/> is not <see cref="NullableDecimal.Null"/> and the <paramref name="format"/> ! /// is invalid for a <see cref="System.Decimal" />. /// </exception> /// <remarks> *************** *** 592,596 **** /// <exception cref="System.FormatException"> /// The length of <paramref name="format"/> is 1, and it is not one of the format specifier characters ! /// defined for DateTimeFormatInfo. /// <para> -or- </para> /// <paramref name="format"/> does not contain a valid custom format pattern. --- 625,629 ---- /// <exception cref="System.FormatException"> /// The length of <paramref name="format"/> is 1, and it is not one of the format specifier characters ! /// defined for <see cref="System.Globalization.DateTimeFormatInfo"/>. /// <para> -or- </para> /// <paramref name="format"/> does not contain a valid custom format pattern. |