Esempio n. 1
0
        public async Task <DesignDocument> GetAsync(string designDocName, GetViewIndexOptions options)
        {
            var uri = GetUri(designDocName, options.IsProduction);

            Logger.LogInformation($"Attempting to get design document {_bucketName}/{designDocName} - {uri}");

            try
            {
                var result = await _client.GetAsync(uri, options.CancellationToken).ConfigureAwait(false);

                if (result.StatusCode == HttpStatusCode.NotFound)
                {
                    throw new DesignDocumentNotFoundException(_bucketName, designDocName);
                }

                result.EnsureSuccessStatusCode();

                var content = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                var designDocument = JsonConvert.DeserializeObject <DesignDocument>(content);
                designDocument.Name = designDocName;

                return(designDocument);
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Failed to get design document {_bucketName}/{designDocName} - {uri}");
                throw;
            }
        }
Esempio n. 2
0
        public static Task <DesignDocument> GetAsync(this IViewManager viewManager, string designDocName, Action <GetViewIndexOptions> configureOptions)
        {
            var options = new GetViewIndexOptions();

            configureOptions(options);

            return(viewManager.GetAsync(designDocName, options));
        }