Skip to content

Commit eac6351

Browse files
author
Ronald Barendse
committed
Simplified value check using type pattern matching
1 parent c3e58df commit eac6351

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Umbraco.Core/PropertyEditors/PropertyValueConverterBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public virtual bool IsConverter(IPublishedPropertyType propertyType)
1818
case PropertyValueLevel.Source:
1919
// the default implementation uses the old magic null & string comparisons,
2020
// other implementations may be more clever, and/or test the final converted object values
21-
return value != null && (!(value is string) || string.IsNullOrWhiteSpace((string)value) == false);
21+
return value != null && (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue));
2222
case PropertyValueLevel.Inter:
2323
return null;
2424
case PropertyValueLevel.Object:
@@ -32,7 +32,7 @@ public virtual bool IsConverter(IPublishedPropertyType propertyType)
3232
public virtual bool HasValue(IPublishedProperty property, string culture, string segment)
3333
{
3434
var value = property.GetSourceValue(culture, segment);
35-
return value != null && (!(value is string) || string.IsNullOrWhiteSpace((string)value) == false);
35+
return value != null && (!(value is string stringValue) || !string.IsNullOrWhiteSpace(stringValue));
3636
}
3737

3838
public virtual Type GetPropertyValueType(IPublishedPropertyType propertyType)

0 commit comments

Comments
 (0)