Saxonite 1.2.11.0
This commit is contained in:
@@ -53,7 +53,7 @@ namespace Sarand.Net.Standard.Base.Bus
|
||||
}
|
||||
public static SysId InvalidOnNull(SysId sysId)
|
||||
{
|
||||
return sysId != null ? sysId : new SysId();
|
||||
return sysId ?? new SysId();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
@@ -126,6 +126,24 @@ namespace Sarand.Net.Standard.Base.Helpers
|
||||
return false;
|
||||
}
|
||||
|
||||
// YouTube URLs. [[https:]//][www.]youtube.com/...
|
||||
private static readonly Regex reYouTubeUrl = new Regex("^(?:(?:http(?:s)?:)?//)?(?:www\\.)?" + Regex.Escape("youtube.com/") + ".+", RegexOptions.IgnoreCase);
|
||||
public static bool IsValidYouTubeUrl(String value)
|
||||
{
|
||||
if (!IsValidUrl(value)) return false;
|
||||
if (reYouTubeUrl.Matches(value).Count > 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Twitch URLs. [[https:]//][www.]twitch.com/...
|
||||
private static readonly Regex reTwitchUrl = new Regex("^(?:(?:http(?:s)?:)?//)?(?:www\\.)?" + Regex.Escape("twitch.tv/") + ".+", RegexOptions.IgnoreCase);
|
||||
public static bool IsValidTwitchUrl(String value)
|
||||
{
|
||||
if (!IsValidUrl(value)) return false;
|
||||
if (reTwitchUrl.Matches(value).Count > 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
/// <summary>
|
||||
/// Ensure that the website address is a valid URL, ie. at least starts with '//'.
|
||||
|
||||
@@ -108,15 +108,21 @@ namespace Sarand.Net.Standard.Base.Utils
|
||||
//-------------------------------------------------------------------
|
||||
public static String EmptyOnNull(String value)
|
||||
{
|
||||
return (value == null ? String.Empty : value);
|
||||
return value ?? String.Empty;
|
||||
}
|
||||
public static String OnEmpty(String value, String defaultValue)
|
||||
/// <summary>Return the first value in the list that is not empty. Default if all are empty is empty string.</summary>
|
||||
public static String OnEmpty(params String[] values)
|
||||
{
|
||||
return (!IsEmpty(value)) ? value : defaultValue;
|
||||
foreach (String value in values)
|
||||
if (!IsEmpty(value)) return value;
|
||||
return "";
|
||||
}
|
||||
public static String OnBlank(String value, String defaultValue)
|
||||
/// <summary>Return the first value in the list that is not blank. Default if all are blank is empty string.</summary>
|
||||
public static String OnBlank(params String[] values)
|
||||
{
|
||||
return (!IsBlank(value)) ? value : defaultValue;
|
||||
foreach (String value in values)
|
||||
if (!IsBlank(value)) return value;
|
||||
return "";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user