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

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

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