mirror of
https://github.com/bitwarden/android.git
synced 2024-12-28 20:08:43 +03:00
31 lines
940 B
C#
31 lines
940 B
C#
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))
|
|
{
|
|
if (value == null)
|
|
{
|
|
return false;
|
|
}
|
|
if (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();
|
|
}
|
|
}
|
|
}
|