using System.Collections;
using System.Linq;

namespace InABox.WPF;

public class EnumerableToBooleanConverter : AbstractConverter<IEnumerable?, bool>
{

    public bool Value { get; set; } = true;
    
    public override bool Convert(IEnumerable? value)
    {
        if (value == null)
            return !Value;
        var enumerable = value as object[] ?? value.Cast<object>().ToArray();
        if (!enumerable.GetEnumerator().MoveNext())
            return !Value;
        return Value;
    }
}