예제 #1
0
        /// <summary>
        ///     Gets an <see cref="ICaptchaValue" /> associated with the specified token.
        /// </summary>
        /// <param name="token">The specified token.</param>
        /// <param name="tokenType">The specified token type.</param>
        /// <returns>
        ///     An instance of <see cref="ICaptchaValue" />.
        /// </returns>
        public virtual ICaptchaValue GetValue(string token, TokenType tokenType)
        {
            Validate.ArgumentNotNullOrEmpty(token, "token");
            ICaptchaValue value;

            switch (tokenType)
            {
            case TokenType.Drawing:
                if (DrawingKeys.TryGetValue(token, out value))
                {
                    DrawingKeys.Remove(token);
                }
                break;

            case TokenType.Validation:
                if (ValidateKeys.TryGetValue(token, out value))
                {
                    ValidateKeys.Remove(token);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("tokenType");
            }
            return(value);
        }
예제 #2
0
        /// <summary>
        ///     Removes the specified token and <see cref="ICaptchaValue" /> to the storage.
        /// </summary>
        /// <param name="token">The specified token.</param>
        public bool Remove(string token)
        {
            Validate.ArgumentNotNullOrEmpty(token, "token");
            var remove     = DrawingKeys.Remove(token);
            var validation = ValidateKeys.Remove(token);

            return(remove || validation);
        }