using System; using System.Globalization; using Avalonia.Data.Converters; namespace NexvaneHub.Converters; /// /// Compares a bound enum value's string representation against ConverterParameter. /// Used for "is this nav item selected" / "is this section visible" bindings. /// public class EnumEqualsConverter : IValueConverter { public static readonly EnumEqualsConverter Instance = new(); public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is null || parameter is null) { return false; } return string.Equals(value.ToString(), parameter.ToString(), StringComparison.OrdinalIgnoreCase); } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { throw new NotSupportedException(); } }