using System;
using System.Collections;
using System.Globalization;
using Xamarin.Forms;

namespace InABox.Mobile
{
    public class EnumerableToBooleanConverter : AbstractConverter<IEnumerable,bool>
    {
        
        public bool TrueValue { get; set; }

        protected override bool Convert(IEnumerable value, object? parameter = null)
        {
            return value != null
                ? value.GetEnumerator().MoveNext() 
                    ? TrueValue 
                    : !TrueValue
                : !TrueValue;
        }
        
        public EnumerableToBooleanConverter()
        {
            TrueValue = true;
        }
        
    }
}