/// <summary>
        /// Creates a new instance of the <see cref="TableAccountSasQueryParameters"/>
        /// type based on the supplied query parameters <paramref name="values"/>.
        /// All SAS-related query parameters will be removed from
        /// <paramref name="values"/>.
        /// </summary>
        /// <param name="values">URI query parameters</param>
        internal TableAccountSasQueryParameters(
            IDictionary <string, string> values)
        {
            // make copy, otherwise we'll get an exception when we remove
            IEnumerable <KeyValuePair <string, string> > kvps = values.ToArray();

            foreach (KeyValuePair <string, string> kv in kvps)
            {
                // these are already decoded
                var isSasKey = true;
                switch (kv.Key.ToUpperInvariant())
                {
                case TableConstants.Sas.Parameters.VersionUpper:
                    _version = kv.Value;
                    break;

                case TableConstants.Sas.Parameters.ResourceTypesUpper:
                    _resourceTypes = TableSasExtensions.ParseResourceTypes(kv.Value);
                    break;

                case TableConstants.Sas.Parameters.ProtocolUpper:
                    _protocol = TableSasExtensions.ParseProtocol(kv.Value);
                    break;

                case TableConstants.Sas.Parameters.StartTimeUpper:
                    _startTime = DateTimeOffset.ParseExact(kv.Value, TableConstants.Sas.SasTimeFormat, CultureInfo.InvariantCulture);
                    break;

                case TableConstants.Sas.Parameters.ExpiryTimeUpper:
                    _expiryTime = DateTimeOffset.ParseExact(kv.Value, TableConstants.Sas.SasTimeFormat, CultureInfo.InvariantCulture);
                    break;

                case TableConstants.Sas.Parameters.IPRangeUpper:
                    _ipRange = TableSasIPRange.Parse(kv.Value);
                    break;

                case TableConstants.Sas.Parameters.IdentifierUpper:
                    _identifier = kv.Value;
                    break;

                case TableConstants.Sas.Parameters.ResourceUpper:
                    _resource = kv.Value;
                    break;

                case TableConstants.Sas.Parameters.PermissionsUpper:
                    _permissions = kv.Value;
                    break;

                case TableConstants.Sas.Parameters.SignatureUpper:
                    _signature = kv.Value;
                    break;

                // We didn't recognize the query parameter
                default:
                    isSasKey = false;
                    break;
                }

                // Remove the query parameter if it's part of the SAS
                if (isSasKey)
                {
                    values.Remove(kv.Key);
                }
            }
        }
        /// <summary>
        /// Creates a new instance of the <see cref="TableAccountSasQueryParameters"/>
        /// type based on the supplied query parameters <paramref name="values"/>.
        /// All SAS-related query parameters will be removed from
        /// <paramref name="values"/>.
        /// </summary>
        /// <param name="values">URI query parameters</param>
        internal TableAccountSasQueryParameters(
            IDictionary <string, string> values)
        {
            foreach (var key in values.Keys.ToList())
            {
                // these are already decoded
                var isSasKey = true;
                switch (key.ToUpperInvariant())
                {
                case TableConstants.Sas.Parameters.VersionUpper:
                    _version = values[key];
                    break;

                case TableConstants.Sas.Parameters.ResourceTypesUpper:
                    _resourceTypes = TableSasExtensions.ParseResourceTypes(values[key]);
                    break;

                case TableConstants.Sas.Parameters.ProtocolUpper:
                    _protocol = TableSasExtensions.ParseProtocol(values[key]);
                    break;

                case TableConstants.Sas.Parameters.StartTimeUpper:
                    _startTime       = ParseSasTime(values[key]);
                    _startTimeString = values[key];
                    break;

                case TableConstants.Sas.Parameters.ExpiryTimeUpper:
                    _expiryTime       = ParseSasTime(values[key]);
                    _expiryTimeString = values[key];
                    break;

                case TableConstants.Sas.Parameters.IPRangeUpper:
                    _ipRange = TableSasIPRange.Parse(values[key]);
                    break;

                case TableConstants.Sas.Parameters.IdentifierUpper:
                    _identifier = values[key];
                    break;

                case TableConstants.Sas.Parameters.ResourceUpper:
                    _resource = values[key];
                    break;

                case TableConstants.Sas.Parameters.PermissionsUpper:
                    _permissions = values[key];
                    break;

                case TableConstants.Sas.Parameters.SignatureUpper:
                    _signature = values[key];
                    break;

                // We didn't recognize the query parameter
                default:
                    isSasKey = false;
                    break;
                }

                // Set the value to null if it's part of the SAS
                if (isSasKey)
                {
                    values[key] = null;
                }
            }
        }