StringArrayToBooleanConverter.cs 519 B

1234567891011121314151617181920212223
  1. using System.Linq;
  2. namespace InABox.Mobile
  3. {
  4. public class StringArrayToBooleanConverter : AbstractConverter<string[],bool>
  5. {
  6. public bool HasValue { get; set; }
  7. protected override bool Convert(string[] value, object? parameter = null)
  8. {
  9. var empty = value?.Any() != true;
  10. return HasValue
  11. ? !empty
  12. : empty;
  13. }
  14. public StringArrayToBooleanConverter()
  15. {
  16. HasValue = true;
  17. }
  18. }
  19. }