StringConverters.cs 947 B

123456789101112131415161718192021222324
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. namespace Avalonia.Data.Converters
  4. {
  5. /// <summary>
  6. /// Provides a set of useful <see cref="IValueConverter"/>s for working with string values.
  7. /// </summary>
  8. public static class StringConverters
  9. {
  10. /// <summary>
  11. /// A value converter that returns true if the input string is null or an empty string.
  12. /// </summary>
  13. public static readonly IValueConverter NullOrEmpty =
  14. new FuncValueConverter<string, bool>(string.IsNullOrEmpty);
  15. /// <summary>
  16. /// A value converter that returns true if the input string is not null or empty.
  17. /// </summary>
  18. public static readonly IValueConverter NotNullOrEmpty =
  19. new FuncValueConverter<string, bool>(x => !string.IsNullOrEmpty(x));
  20. }
  21. }