Skip to content

Commit

Permalink
Simplified value check using type pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Barendse committed Jun 10, 2020
1 parent c3e58df commit eac6351
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public virtual bool IsConverter(IPublishedPropertyType propertyType)
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:
Expand All @@ -32,7 +32,7 @@ public virtual bool IsConverter(IPublishedPropertyType propertyType)
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)
Expand Down

0 comments on commit eac6351

Please sign in to comment.