/// <summary> /// Sets the properties of a queue. /// </summary> /// <param name="properties">The queue's properties to set.</param> /// <returns>true if the properties were successfully written to the queue.</returns> public abstract bool SetProperties(QueueProperties properties);
private static QueueProperties GetPropertiesFromHeaders(HttpWebResponse response) { QueueProperties properties = new QueueProperties(); int prefixLength = StorageHttpConstants.HeaderNames.PrefixForMetadata.Length; foreach (string key in response.Headers.AllKeys) { if (key.Equals(StorageHttpConstants.HeaderNames.ApproximateMessagesCount, StringComparison.OrdinalIgnoreCase)) { properties.ApproximateMessageCount = Convert.ToInt32(response.Headers[key], CultureInfo.InvariantCulture); } else if (key.StartsWith(StorageHttpConstants.HeaderNames.PrefixForMetadata, StringComparison.OrdinalIgnoreCase)) { if (properties.Metadata == null) { properties.Metadata = new NameValueCollection(); } properties.Metadata.Add(key.Substring(prefixLength), response.Headers[key]); } } return properties; }
public override bool SetProperties(QueueProperties properties) { if (properties == null) { throw new ArgumentNullException("properties"); } bool result = false; RetryPolicy(() => { NameValueCollection col = new NameValueCollection(); col.Add(StorageHttpConstants.QueryParams.QueryParamComp, StorageHttpConstants.CompConstants.Metadata); ResourceUriComponents uriComponents; Uri uri = CreateRequestUri(null, col, out uriComponents); HttpWebRequest request = CreateHttpRequest(uri, StorageHttpConstants.HttpMethod.Put, properties.Metadata); _credentials.SignRequest(request, uriComponents); try { using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode == HttpStatusCode.NoContent) { result = true; } else { Utilities.ProcessUnexpectedStatusCode(response); } response.Close(); } } catch (WebException we) { throw Utilities.TranslateWebException(we); } }); return result; }
public override int ApproximateCount() { QueueProperties props = GetProperties(); return(props.ApproximateMessageCount); }