using CloudBuilder.Core.DependencyInjection.Form;
using CloudBuilder.Core.DependencyInjection.Request;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System
{
    public class SearchFilterOperatorPolicy : AbstractPolicy
    {
        public const string EQUAL_TO = "equal_to";//='value'
        public const string CONTAIN = "contain";//like '%value%'        
        public const string START_CONTAIN = "start_contain";//like 'value%'
        public const string END_CONTAIN = "end_contain";//like '%value'
        public const string CN_CONTAIN = "cn_contain";//like N'%value%'
        public const string CN_START_CONTAIN = "cn_start_contain";//like 'value%'
        public const string CN_END_CONTAIN = "cn_end_contain";//like '%value'
        public const string IN_RANGE = "in_range";//in(values)
        public const string NOT_IN_RANGE = "not_in_range";//not in(values)
        public const string NUMBER_GREATER_THAN = "number_greater_than";//>value
        public const string NUMBER_GREATER_THAN_OR_EQUAL_TO = "number_greater_than_or_equal_to";//>=value
        public const string NUMBER_LESS_THAN = "number_less_than";//<value
        public const string NUMBER_LESS_THAN_OR_EQUAL_TO = "number_less_than_or_equal_to";//<=value
        public const string NUMBER_EQUAL_TO = "number_equal_to";//='value'
        public const string BETWEEN = "between";//between >=value && <=value
        public const string DATE_BETWEEN = "date_between";//between >=value && <=value
        public const string DATETIME_BETWEEN = "datetime_between";//between >=value && <=value
        public const string DATE_GREATER_THAN = "date_greater_than";//>value
        public const string DATE_GREATER_THAN_OR_EQUAL_TO = "date_greater_than_or_equal_to";//>=value
        public const string DATE_LESS_THAN = "date_less_than";//<value
        public const string DATE_LESS_THAN_OR_EQUAL_TO = "date_less_than_or_equal_to";//<=value
        public const string DATE_EQUAL_TO = "date_equal_to";//='value'
        public const string CN_MULTIPLE = "cn_multiple";//in(values)
        public const string CN_IN_RANGE = "cn_in_range";//='value'
        public const string MULTIPLE = "multiple";//in(values)
        public const string SINGLE = "single";//='value'

        public static SearchFilterOperatorPolicy instance = null;

        public SearchFilterOperatorPolicy(IContext context) : base(context)
        {
            this.values = new string[] {
                    EQUAL_TO,
                    CONTAIN,
                    START_CONTAIN,
                    END_CONTAIN,
                    CN_CONTAIN,
                    CN_START_CONTAIN,
                    CN_END_CONTAIN,
                    IN_RANGE,
                    NOT_IN_RANGE,
                    NUMBER_GREATER_THAN,
                    NUMBER_GREATER_THAN_OR_EQUAL_TO,
                    NUMBER_LESS_THAN,
                    NUMBER_LESS_THAN_OR_EQUAL_TO,
                    NUMBER_EQUAL_TO,
                    BETWEEN,
                    DATE_BETWEEN,
                    DATE_GREATER_THAN,
                    DATE_GREATER_THAN_OR_EQUAL_TO,
                    DATE_LESS_THAN,
                    DATE_LESS_THAN_OR_EQUAL_TO,
                    DATE_EQUAL_TO,
                    CN_MULTIPLE,
                    CN_IN_RANGE,
                    MULTIPLE,
                    SINGLE
                };
        }

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

    }
}
