BoolConverters.cs 755 B

12345678910111213141516171819202122
  1. using System.Linq;
  2. namespace Avalonia.Data.Converters
  3. {
  4. /// <summary>
  5. /// Provides a set of useful <see cref="IValueConverter"/>s for working with bool values.
  6. /// </summary>
  7. public static class BoolConverters
  8. {
  9. /// <summary>
  10. /// A multi-value converter that returns true if all inputs are true.
  11. /// </summary>
  12. public static readonly IMultiValueConverter And =
  13. new FuncMultiValueConverter<bool, bool>(x => x.All(y => y));
  14. /// <summary>
  15. /// A multi-value converter that returns true if any of the inputs is true.
  16. /// </summary>
  17. public static readonly IMultiValueConverter Or =
  18. new FuncMultiValueConverter<bool, bool>(x => x.Any(y => y));
  19. }
  20. }