internal TableStorageAccount(TableCredentials credentials, TableStorageUri tableStorageUri)
        {
            _tableCredentials = credentials;

            _tableStorageUri = tableStorageUri;
        }
Пример #2
0
 internal TableClient(TableCredentials tableStorageCredentials, TableStorageUri tableStorageUri)
 {
     _credentials     = tableStorageCredentials;
     _tableStorageUri = tableStorageUri;
 }
Пример #3
0
        internal async Task <TableQueryResult <T> > ExecuteQueryAsync <T>(TableCredentials credentials, TableStorageUri storageUri) where T : class
        {
            var result = await ExecutecInternalAsyn(credentials, storageUri);

            return(_entity.DeSerialize <T>(result.ResponseStream, GetPaginationToken(result.Headers)));
        }
Пример #4
0
        private async Task <TableResponse> ExecutecInternalAsyn(TableCredentials credentials, TableStorageUri storageUri)
        {
            var time = DateTimeOffset.UtcNow.UtcDateTime.ToString("R", CultureInfo.InvariantCulture);

            using (var request = new HttpRequestMessage(HttpMethod, storageUri.BuildRequestUri(_tableUri)))
            {
                request.Headers.Add("x-ms-date", time);

                request.Headers.Authorization = credentials.AuthorizationHeader(time, _tableUri.Url);

                if (_operationType == TableOperationType.Insert || _operationType == TableOperationType.InsertEdmType || _operationType == TableOperationType.Update)
                {
                    request.Headers.Add("Prefer", TableConstants.ReturnNoContent);
                    request.Content = _entity.Serialize(GetEntity());
                }

                if (_operationType == TableOperationType.Update || _operationType == TableOperationType.Delete)
                {
                    request.Headers.Add("If-Match", "*");
                }

                using (var cts = new CancellationTokenSource(TableConstants.DefaultRequestTimeout))
                {
                    using (var response = await HttpClientFactory.Client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead,
                                                                                   cts.Token).ConfigureAwait(false))
                    {
                        using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
                        {
                            if (!response.IsSuccessStatusCode)
                            {
                                ThrowHelper.Throw(await stream.StringAsync(), response.StatusCode);
                            }

                            if (_operationType == TableOperationType.Get)
                            {
                                return(new TableResponse(await stream.CopyAsync(), response.StatusCode,
                                                         response.Headers));
                            }

                            return(new TableResponse(response.StatusCode));
                        }
                    }
                }
            }
        }
Пример #5
0
        internal async Task <TableResult <T> > ExecuteAsync <T>(TableCredentials credentials, TableStorageUri storageUri) where T : class
        {
            var result = await ExecutecInternalAsyn(credentials, storageUri);

            if (_operationType == TableOperationType.Get)
            {
                return(_entity.DeSerialize <T>(result.ResponseStream, result.StatusCode));
            }

            return(new TableResult <T>(result.StatusCode));
        }