using System; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using Windows.UI.Xaml; using Windows.UI.Xaml.Data; namespace OwlCore.WinUI.Converters.Bools.Visible { /// /// A converter that converts checks if a string is null or empty and returns a . /// public sealed class NotNullOrEmptyToBoolConverter : IValueConverter { /// /// Checks if a string is null or empty, and returns a . /// /// The string to null or empty check. /// if not null or empty, if null or empty. [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Convert(string? str) => !string.IsNullOrEmpty(str); /// public object Convert(object value, Type targetType, object parameter, string language) { if (value is string str) { return Convert(str); } return false; } /// public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } }