1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-29 04:07:37 +02:00

string has value converter

This commit is contained in:
Kyle Spearrin 2019-04-29 09:31:34 -04:00
parent 8fa2ef863f
commit 65fe0e8f62

View File

@ -0,0 +1,24 @@
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();
}
}
}