mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
string has value converter
This commit is contained in:
parent
8fa2ef863f
commit
65fe0e8f62
1 changed files with 24 additions and 0 deletions
24
src/App/Utilities/StringHasValueConverter.cs
Normal file
24
src/App/Utilities/StringHasValueConverter.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue