bitwarden-android/src/App/Utilities/StringHasValueConverter.cs

25 lines
776 B
C#
Raw Normal View History

2019-04-29 16:31:34 +03:00
using System;
using Xamarin.Forms;
namespace Bit.App.Utilities
{
public class StringHasValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
if(targetType == typeof(bool) && value.GetType() == typeof(string))
{
return !string.IsNullOrWhiteSpace((string)value);
}
throw new InvalidOperationException("The value must be a string with a boolean target.");
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}