Class ProgramTypeUtility
- Namespace
- Songhay
- Assembly
- SonghayCore.dll
Static members for type handling.
public static class ProgramTypeUtility
- Inheritance
-
ProgramTypeUtility
- Inherited Members
Remarks
Most of the Parse methods were originally meant for unboxing values from XML documents.
Methods
ConvertDateTimeFromUnixTime(double)
Converts Unix time stamps to DateTime.
public static DateTime ConvertDateTimeFromUnixTime(double time)
Parameters
Returns
ConvertDateTimeToRfc3339DateTime(DateTime)
Converts the specified DateTime to RFC3339.
public static string ConvertDateTimeToRfc3339DateTime(DateTime utcDateTime)
Parameters
utcDateTimeDateTimeThe UTC date and time.
Returns
ConvertDateTimeToRfc822DateTime(DateTime)
/// Converts the specified DateTime to RFC822.
public static string ConvertDateTimeToRfc822DateTime(DateTime dateTime)
Parameters
dateTimeDateTimeThe date and time.
Returns
Remarks
“Shortcomings of OPML… The RFC 822 date format is considered obsolete, and amongst other things permits the representation of years as two digits. (RFC 822 has been superseded by RFC 2822.) In general, date and time formats should be represented according to RFC 3339.” http://www.answers.com/topic/opml
ConvertDateTimeToUnixTime()
Converts the current time to a Unix time stamp.
public static double ConvertDateTimeToUnixTime()
Returns
ConvertDateTimeToUnixTime(DateTime)
Converts a DateTime to a Unix time stamp.
public static double ConvertDateTimeToUnixTime(DateTime dateValue)
Parameters
Returns
ConvertDateTimeToUtc(DateTime)
Converts a DateTime to UTC (ISO 8601).
[Obsolete("Use `DateTimeExtensions.ToIso8601String` instead.")]
public static string ConvertDateTimeToUtc(DateTime dateValue)
Parameters
Returns
Remarks
For detail, see https://stackoverflow.com/a/1728437/22944.
ConvertInchesToPoints(float)
Converts inches as a float to points.
public static float ConvertInchesToPoints(float inches)
Parameters
inchesfloatThe inches.
Returns
Remarks
1 point = 0.013837 inch
ConvertPointsToInches(float)
Converts points as a float to inches.
public static float ConvertPointsToInches(float points)
Parameters
pointsfloatThe points.
Returns
Remarks
1 point = 0.013837 inch
GenerateRandomPassword(int)
Generates the random password.
public static string GenerateRandomPassword(int passwordLength)
Parameters
passwordLengthintLength of the password.
Returns
Remarks
See “Generate random password in C#” by Mads Kristensen [http://madskristensen.net/post/Generate-random-password-in-C]
IsNullOrEmptyOrNotArray(object?)
Returns true when the specified value
is an empty array, not an array or null.
public static bool IsNullOrEmptyOrNotArray(object? boxedArray)
Parameters
boxedArrayobjectThe specified value.
Returns
IsNullOrEmptyString(object?)
Returns true when the specified value
is null or Empty.
public static bool IsNullOrEmptyString(object? boxedString)
Parameters
boxedStringobjectThe framework value.
Returns
ParseBoolean(object?)
Tries to convert the specified value to the Nullable return type.
public static bool? ParseBoolean(object? value)
Parameters
Returns
ParseBoolean(object?, bool)
Tries to convert the specified value to the Nullable return type.
public static bool? ParseBoolean(object? value, bool supportBitStrings)
Parameters
valueobjectThe specified object box.
supportBitStringsboolWhen
true, support "1" and "0" as Boolean strings.
Returns
ParseBoolean(object?, bool, bool)
Tries to convert the specified value to the Nullable return type.
public static bool? ParseBoolean(object? value, bool supportBitStrings, bool defaultValue)
Parameters
valueobjectThe specified object box.
supportBitStringsboolWhen
true, support "1" and "0" as Boolean strings.defaultValueboolThe default value to return when
Nullable.HasValue == false.
Returns
ParseByte(object?)
Tries to convert the specified value to the Nullable return type.
public static byte? ParseByte(object? value)
Parameters
Returns
ParseByte(object?, byte)
Tries to convert the specified value to the Nullable return type.
public static byte? ParseByte(object? value, byte defaultValue)
Parameters
valueobjectThe specified object box.
defaultValuebyteThe default value to return when
Nullable.HasValue == false.
Returns
ParseDateTime(object?)
Tries to convert the specified value to the Nullable return type.
public static DateTime? ParseDateTime(object? value)
Parameters
Returns
ParseDateTime(object?, DateTime)
Tries to convert the specified value to the Nullable return type.
public static DateTime? ParseDateTime(object? value, DateTime defaultValue)
Parameters
valueobjectThe specified object box.
defaultValueDateTimeThe default value to return when
Nullable.HasValue == false.
Returns
ParseDateTimeWithFormat(object?, string)
Tries to convert the specified value to the Nullable return type.
public static string? ParseDateTimeWithFormat(object? value, string formatExpression)
Parameters
Returns
ParseDateTimeWithFormat(object?, string, string)
Tries to convert the specified value to the Nullable return type.
public static string ParseDateTimeWithFormat(object? value, string formatExpression, string defaultValue)
Parameters
valueobjectThe specified object box.
formatExpressionstringThe string format expression.
defaultValuestringThe default value to return when
Nullable.HasValue == false.
Returns
ParseDecimal(object?)
Tries to convert the specified value to the Nullable return type.
public static decimal? ParseDecimal(object? value)
Parameters
Returns
ParseDecimal(object?, decimal)
Tries to convert the specified value to the Nullable return type.
public static decimal? ParseDecimal(object? value, decimal defaultValue)
Parameters
valueobjectThe specified object box.
defaultValuedecimalThe default value to return when
Nullable.HasValue == false.
Returns
ParseDouble(object?)
Tries to convert the specified value to the Nullable return type.
public static double? ParseDouble(object? value)
Parameters
Returns
ParseDouble(object?, double)
Tries to convert the specified value to the Nullable return type.
public static double? ParseDouble(object? value, double defaultValue)
Parameters
valueobjectThe specified object box.
defaultValuedoubleThe default value to return when
Nullable.HasValue == false.
Returns
ParseEnum<TEnum>(string, TEnum)
Tries to convert the specified value to the Enum return type.
public static TEnum ParseEnum<TEnum>(string value, TEnum defaultValue) where TEnum : struct
Parameters
valuestringThe value.
defaultValueTEnumThe default value.
Returns
- TEnum
Type Parameters
TEnumThe type of the enum.
Remarks
For background, see http://stackoverflow.com/a/15017429/22944
ParseInt16(object?)
Tries to convert the specified value to the Nullable return type.
public static short? ParseInt16(object? value)
Parameters
Returns
ParseInt16(object?, short)
Tries to convert the specified value to the Nullable return type.
public static short? ParseInt16(object? value, short defaultValue)
Parameters
valueobjectThe specified object box.
defaultValueshortThe default value to return when
Nullable.HasValue == false.
Returns
ParseInt32(object?)
Tries to convert the specified value to the Nullable return type.
public static int? ParseInt32(object? value)
Parameters
Returns
ParseInt32(object?, int)
Tries to convert the specified value to the Nullable return type.
public static int? ParseInt32(object? value, int defaultValue)
Parameters
valueobjectThe specified object box.
defaultValueintThe default value to return when
Nullable.HasValue == false.
Returns
ParseInt64(object?)
Tries to convert the specified value to the Nullable return type.
public static long? ParseInt64(object? value)
Parameters
Returns
ParseInt64(object?, long)
Tries to convert the specified value to the Nullable return type.
public static long? ParseInt64(object? value, long defaultValue)
Parameters
valueobjectThe specified object box.
defaultValuelongThe default value to return when
Nullable.HasValue == false.
Returns
ParseRfc3339DateTime(string?)
Parses the RFC3339 date and time.
public static DateTime ParseRfc3339DateTime(string? value)
Parameters
valuestringThe value.
Returns
Remarks
This member is based on patterns in the Argotic Syndication Framework (http://www.codeplex.com/Argotic).
ParseRfc822DateTime(string)
Parses the RFC822 date and time.
public static DateTime ParseRfc822DateTime(string value)
Parameters
valuestringThe value.
Returns
Remarks
This member is based on patterns in the Argotic Syndication Framework (http://www.codeplex.com/Argotic).
ParseString(object?)
Tries to convert the specified value to a string.
public static string? ParseString(object? value)
Parameters
Returns
ParseString(object?, string?)
Tries to convert the specified value to a string.
public static string? ParseString(object? value, string? defaultValue)
Parameters
Returns
SqlDatabaseNull()
Returns the conventional database null (DBNull) for Microsoft SQL Server systems.
public static DBNull SqlDatabaseNull()
Returns
TryParseRfc3339DateTime(string, out DateTime)
Tries the parse RFC3339 date and time.
public static bool TryParseRfc3339DateTime(string value, out DateTime result)
Parameters
Returns
Remarks
This member is based on patterns in the Argotic Syndication Framework (http://www.codeplex.com/Argotic).
TryParseRfc822DateTime(string, out DateTime)
Tries the parse RFC822 date and time.
public static bool TryParseRfc822DateTime(string value, out DateTime result)
Parameters
Returns
Remarks
This member is based on patterns in the Argotic Syndication Framework (http://www.codeplex.com/Argotic).