예제 #1
0
 private ContainerProperties ContainerPropertiesFromResponse(HttpWebResponse response)
 {
     ContainerProperties prop = new ContainerProperties(ContainerName);
     prop.LastModifiedTime = response.LastModified.ToUniversalTime();
     prop.ETag = response.Headers[StorageHttpConstants.HeaderNames.ETag];
     prop.Uri = containerUri;
     prop.Metadata = MetadataFromHeaders(response.Headers);
     return prop;
 }
예제 #2
0
        private static ListContainersResult ListContainersResultFromResponse(Stream responseBody)
        {
            List<ContainerProperties> containers = new List<ContainerProperties>();
            string nextMarker = null;

            XmlDocument doc = new XmlDocument();
            try
            {
                doc.Load(responseBody);
            }
            catch (XmlException xe)
            {
                throw new StorageServerException(StorageErrorCode.ServiceBadResponse,
                    "The result of a ListBlobContainers operation could not be parsed", default(HttpStatusCode), xe);
            }

            // Get all the containers returned as the listing results
            XmlNodeList containerNodes = doc.SelectNodes(XPathQueryHelper.ContainerQuery);

            foreach (XmlNode containerNode in containerNodes)
            {
                DateTime? lastModified = XPathQueryHelper.LoadSingleChildDateTimeValue(
                    containerNode, StorageHttpConstants.XmlElementNames.LastModified, false);

                string eTag = XPathQueryHelper.LoadSingleChildStringValue(
                    containerNode, StorageHttpConstants.XmlElementNames.Etag, false);

                string containerUri = XPathQueryHelper.LoadSingleChildStringValue(
                    containerNode, StorageHttpConstants.XmlElementNames.Url, true);

                string containerName = XPathQueryHelper.LoadSingleChildStringValue(
                    containerNode, StorageHttpConstants.XmlElementNames.Name, true);

                ContainerProperties properties = new ContainerProperties(containerName);
                if (lastModified.HasValue)
                    properties.LastModifiedTime = lastModified.Value;
                properties.ETag = eTag;

                Uri uri = null;
                Uri.TryCreate(containerUri, UriKind.Absolute, out uri);
                properties.Uri = uri;

                containers.Add(properties);
            }

            // Get the nextMarker
            XmlNode nextMarkerNode = doc.SelectSingleNode(XPathQueryHelper.NextMarkerQuery);
            if (nextMarkerNode != null && nextMarkerNode.FirstChild != null)
            {
                nextMarker = nextMarkerNode.FirstChild.Value;
            }

            return new ListContainersResult(containers, nextMarker);
        }