コード例 #1
0
        public ResponseWithHeaders <TableServiceProperties, ServiceGetPropertiesHeaders> GetProperties(int?timeout = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateGetPropertiesRequest(timeout);
            _pipeline.Send(message, cancellationToken);
            var headers = new ServiceGetPropertiesHeaders(message.Response);

            switch (message.Response.Status)
            {
            case 200:
            {
                TableServiceProperties value = default;
                var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                if (document.Element("StorageServiceProperties") is XElement storageServicePropertiesElement)
                {
                    value = TableServiceProperties.DeserializeTableServiceProperties(storageServicePropertiesElement);
                }
                return(ResponseWithHeaders.FromValue(value, headers, message.Response));
            }

            default:
                throw _clientDiagnostics.CreateRequestFailedException(message.Response);
            }
        }
コード例 #2
0
        public async Task <ResponseWithHeaders <TableServiceProperties, ServiceGetPropertiesHeaders> > GetPropertiesAsync(int?timeout = null, string requestId = null, CancellationToken cancellationToken = default)
        {
            using var message = CreateGetPropertiesRequest(timeout, requestId);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            var headers = new ServiceGetPropertiesHeaders(message.Response);

            switch (message.Response.Status)
            {
            case 200:
            {
                TableServiceProperties value = default;
                var document = XDocument.Load(message.Response.ContentStream, LoadOptions.PreserveWhitespace);
                if (document.Element("TableServiceProperties") is XElement tableServicePropertiesElement)
                {
                    value = TableServiceProperties.DeserializeTableServiceProperties(tableServicePropertiesElement);
                }
                return(ResponseWithHeaders.FromValue(value, headers, message.Response));
            }

            default:
                throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false);
            }
        }