From eac6351c3f0336e8531d6c75126aa39c47dd5add Mon Sep 17 00:00:00 2001 From: Ronald Barendse Date: Thu, 11 Jun 2020 00:49:44 +0200 Subject: [PATCH] Simplified value check using type pattern matching --- .../PropertyEditors/PropertyValueConverterBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs index 57474eb2e1..be8b0619f5 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs @@ -18,7 +18,7 @@ namespace Umbraco.Core.PropertyEditors case PropertyValueLevel.Source: // the default implementation uses the old magic null & string comparisons, // other implementations may be more clever, and/or test the final converted object values - return value != null && (!(value is string) || string.IsNullOrWhiteSpace((string)value) == false); + return value != null && (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue)); case PropertyValueLevel.Inter: return null; case PropertyValueLevel.Object: @@ -32,7 +32,7 @@ namespace Umbraco.Core.PropertyEditors public virtual bool HasValue(IPublishedProperty property, string culture, string segment) { var value = property.GetSourceValue(culture, segment); - return value != null && (!(value is string) || string.IsNullOrWhiteSpace((string)value) == false); + return value != null && (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue)); } public virtual Type GetPropertyValueType(IPublishedPropertyType propertyType)