null check

This commit is contained in:
Kyle Spearrin 2019-04-29 09:59:33 -04:00
parent 69eeb8bd23
commit a75295662c

View file

@ -8,10 +8,17 @@ namespace Bit.App.Utilities
public object Convert(object value, Type targetType, object parameter, public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture) System.Globalization.CultureInfo culture)
{ {
if(targetType == typeof(bool) && value.GetType() == typeof(string)) if(targetType == typeof(bool))
{
if(value == null)
{
return false;
}
if(value.GetType() == typeof(string))
{ {
return !string.IsNullOrWhiteSpace((string)value); return !string.IsNullOrWhiteSpace((string)value);
} }
}
throw new InvalidOperationException("The value must be a string with a boolean target."); throw new InvalidOperationException("The value must be a string with a boolean target.");
} }