/// <summary>
        /// 新增令牌
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static TokenEntity AddToken(int requestUserId, string requestAccount, int expiry)
        {
            var token = new TokenEntity();

            token.AccessToken    = GenerateTokenCode();
            token.RefreshToken   = GenerateTokenCode();
            token.RequestAccount = requestAccount;
            token.RequestUserId  = requestUserId;
            token.Expiry         = expiry;
            token.CreateTime     = DateTime.Now;
            token.ExpiryDate     = DateTime.Now.AddSeconds(expiry);

            // 删除旧的Token
            //var currentToken = redisHelper.Get<TokenEntity>(string.Format("{0}:{1}", REDIS_KEY_TOKEN_USER, token.RequestUserId.ToString()));
            //if (currentToken != null)
            //{
            //    redisHelper.Remove(string.Format("{0}:{1}", REDIS_KEY_TOKEN_ACCESSTOKEN, currentToken.AccessToken));
            //}

            // 添加新的Token
            redisHelper.Set(string.Format("{0}:{1}", REDIS_KEY_TOKEN_ACCESSTOKEN, token.AccessToken), token, expiry);
            //redisHelper.Set(string.Format("{0}:{1}", REDIS_KEY_TOKEN_USER, token.RequestUserId.ToString()), token, expiry);
            redisHelper.Set(string.Format("{0}:{1}", REDIS_KEY_TOKEN_REFRESHTOKEN, token.RefreshToken), token.AccessToken, expiry * 12);
            return(token);
        }
        public static bool Execute(AuthorizeTypeEnum type, TokenEntity token)
        {
            List <IAuthorizeProvider> tempProviders = null;

            switch (type)
            {
            case AuthorizeTypeEnum.API:
                lock (_apiLock)
                {
                    tempProviders = _apiProviders;
                }
                break;

            case AuthorizeTypeEnum.MVC:
                lock (_mvcLock)
                {
                    tempProviders = _mvcProviders;
                }
                break;
            }

            if (tempProviders == null)
            {
                return(true);
            }

            foreach (var p in tempProviders)
            {
                if (!p.Execute(token))
                {
                    return(false);
                }
            }

            return(true);
        }