Saxonite 1.2.11.0

This commit is contained in:
Andy Howard
2023-07-06 18:35:55 +01:00
parent b39b28d2d2
commit 048194e935
3 changed files with 82 additions and 58 deletions
+1 -1
View File
@@ -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 '//'.
+11 -5
View File
@@ -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 "";
}
//-------------------------------------------------------------------