示例#1
0
 /// <summary>
 /// Creates a new TableAccountSasQueryParameters instance.
 /// </summary>
 internal TableAccountSasQueryParameters(
     string version,
     TableAccountSasResourceTypes?resourceTypes,
     SasProtocol protocol,
     DateTimeOffset startsOn,
     DateTimeOffset expiresOn,
     SasIPRange ipRange,
     string identifier,
     string resource,
     string permissions,
     string signature)
 {
     _version       = version;
     _resourceTypes = resourceTypes;
     _protocol      = protocol;
     _startTime     = startsOn;
     _expiryTime    = expiresOn;
     _ipRange       = ipRange;
     _identifier    = identifier;
     _resource      = resource;
     _permissions   = permissions;
     _signature     = signature;
 }
示例#2
0
        /// <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 = SasExtensions.ParseResourceTypes(kv.Value);
                    break;

                case TableConstants.Sas.Parameters.ProtocolUpper:
                    _protocol = SasExtensions.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 = SasIPRange.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);
                }
            }
        }