StringNullOrEmpty.cs 990 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Globalization;
  5. using Perspex;
  6. using Perspex.Markup;
  7. namespace XamlTestApplication
  8. {
  9. public class StringNullOrEmpty : IValueConverter
  10. {
  11. public static readonly StringNullOrEmpty Instance = new StringNullOrEmpty();
  12. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  13. {
  14. if (value == null)
  15. {
  16. return true;
  17. }
  18. else
  19. {
  20. var s = value as string;
  21. return s != null ? string.IsNullOrEmpty(s) : PerspexProperty.UnsetValue;
  22. }
  23. }
  24. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  25. {
  26. throw new NotImplementedException();
  27. }
  28. }
  29. }