mirror of
https://github.com/bitwarden/mobile
synced 2025-02-02 11:37:14 +01:00
string has value converter
This commit is contained in:
parent
8fa2ef863f
commit
65fe0e8f62
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…
x
Reference in New Issue
Block a user