예제 #1
0
        async Task ReadXmlAsync(XmlReader reader)
        {
            CommonUtility.AssertNotNull("reader", reader);

            await reader.ReadAsync().ConfigureAwait(false);

            if (reader.NodeType == XmlNodeType.Comment)
            {
                await reader.ReadAsync().ConfigureAwait(false);
            }

            await reader.ReadStartElementAsync().ConfigureAwait(false);

            this.HttpStatusCode    = int.Parse(await CommonUtility.ReadElementAsStringAsync("HTTPStatusCode", reader).ConfigureAwait(false), CultureInfo.InvariantCulture);
            this.HttpStatusMessage = await CommonUtility.ReadElementAsStringAsync("HttpStatusMessage", reader).ConfigureAwait(false);

            StorageLocation targetLocation;

            if (Enum.TryParse <StorageLocation>(await CommonUtility.ReadElementAsStringAsync("TargetLocation", reader).ConfigureAwait(false), out targetLocation))
            {
                this.TargetLocation = targetLocation;
            }

            this.ServiceRequestID = await CommonUtility.ReadElementAsStringAsync("ServiceRequestID", reader).ConfigureAwait(false);

            this.ContentMd5 = await CommonUtility.ReadElementAsStringAsync("ContentMd5", reader).ConfigureAwait(false);

            this.Etag = await CommonUtility.ReadElementAsStringAsync("Etag", reader).ConfigureAwait(false);

            this.RequestDate = await CommonUtility.ReadElementAsStringAsync("RequestDate", reader).ConfigureAwait(false);

            try
            {
                this.ErrorCode = await CommonUtility.ReadElementAsStringAsync("ErrorCode", reader).ConfigureAwait(false);
            }
            catch (XmlException)
            {
                /* The ErrorCode property only exists after service version 07-17.
                 * If it is not present, we are reading an old version and can ignore this property.
                 */
            }
#if WINDOWS_RT || NETCORE
            this.StartTime = DateTimeOffset.Parse(await CommonUtility.ReadElementAsStringAsync("StartTime", reader).ConfigureAwait(false), CultureInfo.InvariantCulture);
            this.EndTime   = DateTimeOffset.Parse(await CommonUtility.ReadElementAsStringAsync("EndTime", reader).ConfigureAwait(false), CultureInfo.InvariantCulture);
#else
            this.StartTime = DateTime.Parse(await CommonUtility.ReadElementAsStringAsync("StartTime", reader).ConfigureAwait(false), CultureInfo.InvariantCulture);
            this.EndTime   = DateTime.Parse(await CommonUtility.ReadElementAsStringAsync("EndTime", reader).ConfigureAwait(false), CultureInfo.InvariantCulture);
#endif
            this.ExtendedErrorInformation = new StorageExtendedErrorInformation();
            await this.ExtendedErrorInformation.ReadXmlAsync(reader, CancellationToken.None).ConfigureAwait(false);

#if WINDOWS_RT || NETCORE
            this.ExceptionInfo = await ExceptionInfo.ReadFromXMLReaderAsync(reader).ConfigureAwait(false);
#endif
            // End request Result
            await reader.ReadEndElementAsync().ConfigureAwait(false);
        }