Allowed IfNullOrWhiteSpace to take null input. (#12328)
This commit is contained in:
@@ -365,7 +365,7 @@ namespace Umbraco.Extensions
|
||||
/// returns <see langword="false"/>.</returns>
|
||||
public static bool IsNullOrWhiteSpace(this string? value) => string.IsNullOrWhiteSpace(value);
|
||||
|
||||
public static string? IfNullOrWhiteSpace(this string str, string? defaultValue)
|
||||
public static string? IfNullOrWhiteSpace(this string? str, string? defaultValue)
|
||||
{
|
||||
return str.IsNullOrWhiteSpace() ? defaultValue : str;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Umbraco.Extensions;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Services
|
||||
{
|
||||
@@ -22,9 +22,9 @@ namespace Umbraco.Cms.Core.Services
|
||||
/// </remarks>
|
||||
public Ordering(string? orderBy, Direction direction = Direction.Ascending, string? culture = null, bool isCustomField = false)
|
||||
{
|
||||
OrderBy = orderBy?.IfNullOrWhiteSpace(null); // empty is null and means, not sorting
|
||||
OrderBy = orderBy.IfNullOrWhiteSpace(null); // empty is null and means, not sorting
|
||||
Direction = direction;
|
||||
Culture = culture?.IfNullOrWhiteSpace(string.Empty); // empty is "" and means, invariant
|
||||
Culture = culture.IfNullOrWhiteSpace(string.Empty); // empty is "" and means, invariant
|
||||
IsCustomField = isCustomField;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
||||
}
|
||||
|
||||
text = text.Substring(1);
|
||||
return CultureDictionary[text]?.IfNullOrWhiteSpace(text);
|
||||
return CultureDictionary[text].IfNullOrWhiteSpace(text);
|
||||
}
|
||||
|
||||
protected ActionResult<TContentType?> PerformPostSave<TContentTypeDisplay, TContentTypeSave, TPropertyType>(
|
||||
|
||||
@@ -252,7 +252,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
|
||||
var culture = queryStrings["culture"].TryConvertTo<string>();
|
||||
|
||||
//if this is null we'll set it to the default.
|
||||
var cultureVal = (culture.Success ? culture.Result : null)?.IfNullOrWhiteSpace(_localizationService.GetDefaultLanguageIsoCode());
|
||||
var cultureVal = (culture.Success ? culture.Result : null).IfNullOrWhiteSpace(_localizationService.GetDefaultLanguageIsoCode());
|
||||
|
||||
// set names according to variations
|
||||
foreach (var entity in result.Value!)
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
|
||||
|
||||
nodes.AddRange(_memberTypeService.GetAll()
|
||||
.Select(memberType =>
|
||||
CreateTreeNode(memberType.Alias, id, queryStrings, memberType.Name, memberType.Icon?.IfNullOrWhiteSpace(Constants.Icons.Member), true,
|
||||
CreateTreeNode(memberType.Alias, id, queryStrings, memberType.Name, memberType.Icon.IfNullOrWhiteSpace(Constants.Icons.Member), true,
|
||||
queryStrings.GetRequiredValue<string>("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + memberType.Alias)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user