using System;
using System.ComponentModel;

namespace InABox.Mobile
{
    public class StringToBooleanConverter : AbstractConverter<String,bool>
    {
        public bool HasValue { get; set; }

        protected override bool Convert(string value, object? parameter = null)
        {
            var empty = String.IsNullOrWhiteSpace(value);
            return HasValue 
                ? !empty 
                : empty;
        }

        public StringToBooleanConverter()
        {
            HasValue = true;
        }
        
    }
}