﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ctrip.SOA.Comm.Check
{
    internal abstract class ClientCheck
    {
       

        /// <summary>
        /// 验证时的信息
        /// </summary>
        public string Message
        {
            get;
            set;
        }

        public abstract bool IsValid(RequestHead header);

        public static bool ValidateAll(RequestHead header, ref string message)
        {
            ClientCheck[] checks = new ClientCheck[]{ 
                                                  new ClientRequstTypeCheck(),//必须放在第一个
                                                  new ClientIPAddressCheck(),
                                                  new ClientPermissionCheck()
                                              };

            foreach (ClientCheck check in checks)
            {
                if (check.IsValid(header) == false)
                {
                    message = check.Message;
                    return false;
                }
            }

            return true;
        }
    }
}
