using System; using System.Diagnostics.Contracts; using System.Globalization; using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Data; namespace OwlCore.Wpf.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, CultureInfo culture) { if (value is string str) { return Convert(str); } return false; } /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }