Table of Contents

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

time double

A double.

Returns

DateTime

A DateTime.

ConvertDateTimeToRfc3339DateTime(DateTime)

Converts the specified DateTime to RFC3339.

public static string ConvertDateTimeToRfc3339DateTime(DateTime utcDateTime)

Parameters

utcDateTime DateTime

The UTC date and time.

Returns

string

ConvertDateTimeToRfc822DateTime(DateTime)

/// Converts the specified DateTime to RFC822.

public static string ConvertDateTimeToRfc822DateTime(DateTime dateTime)

Parameters

dateTime DateTime

The date and time.

Returns

string

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

double

A double.

ConvertDateTimeToUnixTime(DateTime)

Converts a DateTime to a Unix time stamp.

public static double ConvertDateTimeToUnixTime(DateTime dateValue)

Parameters

dateValue DateTime

The DateTime.

Returns

double

A double.

ConvertDateTimeToUtc(DateTime)

Converts a DateTime to UTC (ISO 8601).

[Obsolete("Use `DateTimeExtensions.ToIso8601String` instead.")]
public static string ConvertDateTimeToUtc(DateTime dateValue)

Parameters

dateValue DateTime

The DateTime.

Returns

string

Remarks

ConvertInchesToPoints(float)

Converts inches as a float to points.

public static float ConvertInchesToPoints(float inches)

Parameters

inches float

The inches.

Returns

float

Remarks

1 point = 0.013837 inch

ConvertPointsToInches(float)

Converts points as a float to inches.

public static float ConvertPointsToInches(float points)

Parameters

points float

The points.

Returns

float

Remarks

1 point = 0.013837 inch

GenerateRandomPassword(int)

Generates the random password.

public static string GenerateRandomPassword(int passwordLength)

Parameters

passwordLength int

Length of the password.

Returns

string

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

boxedArray object

The specified value.

Returns

bool

IsNullOrEmptyString(object?)

Returns true when the specified value is null or Empty.

public static bool IsNullOrEmptyString(object? boxedString)

Parameters

boxedString object

The framework value.

Returns

bool

ParseBoolean(object?)

Tries to convert the specified value to the Nullable return type.

public static bool? ParseBoolean(object? value)

Parameters

value object

The specified object box.

Returns

bool?

Always returns a Nullable as parse failure means HasValue is false.

ParseBoolean(object?, bool)

Tries to convert the specified value to the Nullable return type.

public static bool? ParseBoolean(object? value, bool supportBitStrings)

Parameters

value object

The specified object box.

supportBitStrings bool

When true, support "1" and "0" as Boolean strings.

Returns

bool?

Always returns a Nullable as parse failure means HasValue is false.

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

value object

The specified object box.

supportBitStrings bool

When true, support "1" and "0" as Boolean strings.

defaultValue bool

The default value to return when Nullable.HasValue == false.

Returns

bool?

Always returns a Nullable as parse failure means HasValue is false.

ParseByte(object?)

Tries to convert the specified value to the Nullable return type.

public static byte? ParseByte(object? value)

Parameters

value object

The specified object box.

Returns

byte?

Always returns a Nullable as parse failure means HasValue is false.

ParseByte(object?, byte)

Tries to convert the specified value to the Nullable return type.

public static byte? ParseByte(object? value, byte defaultValue)

Parameters

value object

The specified object box.

defaultValue byte

The default value to return when Nullable.HasValue == false.

Returns

byte?

Always returns a Nullable as parse failure means HasValue is false.

ParseDateTime(object?)

Tries to convert the specified value to the Nullable return type.

public static DateTime? ParseDateTime(object? value)

Parameters

value object

The specified object box.

Returns

DateTime?

Always returns a Nullable as parse failure means HasValue is false.

ParseDateTime(object?, DateTime)

Tries to convert the specified value to the Nullable return type.

public static DateTime? ParseDateTime(object? value, DateTime defaultValue)

Parameters

value object

The specified object box.

defaultValue DateTime

The default value to return when Nullable.HasValue == false.

Returns

DateTime?

Always returns a Nullable as parse failure means HasValue is false.

ParseDateTimeWithFormat(object?, string)

Tries to convert the specified value to the Nullable return type.

public static string? ParseDateTimeWithFormat(object? value, string formatExpression)

Parameters

value object

The specified object box.

formatExpression string

The string format expression.

Returns

string

Always returns a Nullable as parse failure means HasValue is false.

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

value object

The specified object box.

formatExpression string

The string format expression.

defaultValue string

The default value to return when Nullable.HasValue == false.

Returns

string

Always returns a Nullable as parse failure means HasValue is false.

ParseDecimal(object?)

Tries to convert the specified value to the Nullable return type.

public static decimal? ParseDecimal(object? value)

Parameters

value object

The specified object box.

Returns

decimal?

Always returns a Nullable as parse failure means HasValue is false.

ParseDecimal(object?, decimal)

Tries to convert the specified value to the Nullable return type.

public static decimal? ParseDecimal(object? value, decimal defaultValue)

Parameters

value object

The specified object box.

defaultValue decimal

The default value to return when Nullable.HasValue == false.

Returns

decimal?

Always returns a Nullable as parse failure means HasValue is false.

ParseDouble(object?)

Tries to convert the specified value to the Nullable return type.

public static double? ParseDouble(object? value)

Parameters

value object

The specified object box.

Returns

double?

Always returns a Nullable as parse failure means HasValue is false.

ParseDouble(object?, double)

Tries to convert the specified value to the Nullable return type.

public static double? ParseDouble(object? value, double defaultValue)

Parameters

value object

The specified object box.

defaultValue double

The default value to return when Nullable.HasValue == false.

Returns

double?

Always returns a Nullable as parse failure means HasValue is false.

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

value string

The value.

defaultValue TEnum

The default value.

Returns

TEnum

Type Parameters

TEnum

The type of the enum.

Remarks

ParseInt16(object?)

Tries to convert the specified value to the Nullable return type.

public static short? ParseInt16(object? value)

Parameters

value object

The specified object box.

Returns

short?

Always returns a Nullable as parse failure means HasValue is false.

ParseInt16(object?, short)

Tries to convert the specified value to the Nullable return type.

public static short? ParseInt16(object? value, short defaultValue)

Parameters

value object

The specified object box.

defaultValue short

The default value to return when Nullable.HasValue == false.

Returns

short?

Always returns a Nullable as parse failure means HasValue is false.

ParseInt32(object?)

Tries to convert the specified value to the Nullable return type.

public static int? ParseInt32(object? value)

Parameters

value object

The specified object box.

Returns

int?

Always returns a Nullable as parse failure means HasValue is false.

ParseInt32(object?, int)

Tries to convert the specified value to the Nullable return type.

public static int? ParseInt32(object? value, int defaultValue)

Parameters

value object

The specified object box.

defaultValue int

The default value to return when Nullable.HasValue == false.

Returns

int?

Always returns a Nullable as parse failure means HasValue is false.

ParseInt64(object?)

Tries to convert the specified value to the Nullable return type.

public static long? ParseInt64(object? value)

Parameters

value object

The specified object box.

Returns

long?

Always returns a Nullable as parse failure means HasValue is false.

ParseInt64(object?, long)

Tries to convert the specified value to the Nullable return type.

public static long? ParseInt64(object? value, long defaultValue)

Parameters

value object

The specified object box.

defaultValue long

The default value to return when Nullable.HasValue == false.

Returns

long?

Always returns a Nullable as parse failure means HasValue is false.

ParseRfc3339DateTime(string?)

Parses the RFC3339 date and time.

public static DateTime ParseRfc3339DateTime(string? value)

Parameters

value string

The value.

Returns

DateTime

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

value string

The value.

Returns

DateTime

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

value object

The specified object box.

Returns

string

ParseString(object?, string?)

Tries to convert the specified value to a string.

public static string? ParseString(object? value, string? defaultValue)

Parameters

value object

The value.

defaultValue string

The default value.

Returns

string

SqlDatabaseNull()

Returns the conventional database null (DBNull) for Microsoft SQL Server systems.

public static DBNull SqlDatabaseNull()

Returns

DBNull

DBNull

TryParseRfc3339DateTime(string, out DateTime)

Tries the parse RFC3339 date and time.

public static bool TryParseRfc3339DateTime(string value, out DateTime result)

Parameters

value string

The value.

result DateTime

The result.

Returns

bool

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

value string

The value.

result DateTime

The result.

Returns

bool

Remarks

This member is based on patterns in the Argotic Syndication Framework (http://www.codeplex.com/Argotic).