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)
|
|
|
|
|
{
|
2020-03-28 16:16:28 +03:00
|
|
|
|
if (targetType == typeof(bool))
|
2019-04-29 16:31:34 +03:00
|
|
|
|
{
|
2020-03-28 16:16:28 +03:00
|
|
|
|
if (value == null)
|
2019-04-29 16:59:33 +03:00
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2020-03-28 16:16:28 +03:00
|
|
|
|
if (value.GetType() == typeof(string))
|
2019-04-29 16:59:33 +03:00
|
|
|
|
{
|
|
|
|
|
return !string.IsNullOrWhiteSpace((string)value);
|
|
|
|
|
}
|
2019-04-29 16:31:34 +03:00
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|