using System;
using System.Collections;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using Windows.UI.Xaml.Data;
namespace OwlCore.WinUI.Converters.Bools
{
///
/// A converter that converts a given to an bool based on the presence of any items in the .
///
public sealed class CollectionAnyToBoolConverter : IValueConverter
{
///
/// Gets whether or not a collection is not empty.
///
/// The collection to check.
/// Whether or not the colleciton contains any elements
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool Convert(ICollection collection) => collection.Count > 0;
///
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value is ICollection collection)
{
return Convert(collection);
}
return false;
}
///
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}