
using CloudBuilder.Core.DependencyInjection.Form;
using CloudBuilder.Core.DependencyInjection.Request;
using CloudBuilder.Core.Policy;
using Microsoft.Extensions.DependencyInjection;

namespace System
{
    public class YesNoPolicy : AbstractPolicy
    {
        public const string YES = "Y";
        public const string NO = "N";

        public static YesNoPolicy instance = null;

        public YesNoPolicy(IContext context) : base(context)
        {
            this.values = new string[] { YES, NO };
        }

        public static YesNoPolicy GetInstance()
        {
            instance = ApplicationServiceContext.ServiceProvider.GetKeyedService<YesNoPolicy>(typeof(YesNoPolicy).Name);
            return instance;
        }

        public static bool IsYes(string value)
        {
            return value == YES;
        }

        public static string IsChecked(string value)
        {
            if (value == YES) return "checked";
            return null;
        }
    }
}
