/// <constructor /> public DatabaseApi(CouchApi parent, DbUriConstructor uriConstructor) { if (parent == null) throw new ArgumentNullException("parent"); this.parent = parent; this.uriConstructor = uriConstructor; Synchronously = new SynchronousDatabaseApi(this); }
/// <constructor /> public DatabaseApi(CouchApi parent, DbUriConstructor uriConstructor) { if (parent == null) { throw new ArgumentNullException("parent"); } this.parent = parent; this.uriConstructor = uriConstructor; Synchronously = new SynchronousDatabaseApi(this); }
public static async Task <Document> Start( DbUriConstructor uriConstructor, DatabaseApi databaseApi, CouchApi couchApi, string documentId, string revision, AdditionalDocumentProperty additionalProperties) { var documentUri = uriConstructor.GetFullDocumentUri(documentId, revision, additionalProperties); var request = new HttpRequestMessage(HttpMethod.Get, documentUri); var response = await couchApi.RequestCouchDb(request); if (!response.IsSuccessStatusCode) { var error = new CouchError(couchApi.Settings.Serializer, response); error.ThrowDatabaseMissingExceptionIfNedded(uriConstructor); if (response.StatusCode == HttpStatusCode.NotFound) { return(null); } error.ThrowCouchCommunicationException(); } var content = response.Content; var mediaType = content.Headers.ContentType != null? content.Headers.ContentType.MediaType: "<unknown>"; switch (mediaType) { case MediaType.Json: return(ReadDocument( databaseApi, await content.ReadAsUtf8TextReaderAsync() )); case MediaType.Multipart: return(await ReadMultipart(databaseApi, content)); default: throw new CouchCommunicationException( "Unexpected media type response recived requesting CouchDB document: {0}", mediaType); } }
public static async Task<Document> Start( DbUriConstructor uriConstructor, DatabaseApi databaseApi, CouchApi couchApi, string documentId, string revision, AdditionalDocumentProperty additionalProperties) { var documentUri = uriConstructor.GetFullDocumentUri(documentId, revision, additionalProperties); var request = new HttpRequestMessage(HttpMethod.Get, documentUri); var response = await couchApi.RequestCouchDb(request); if (!response.IsSuccessStatusCode) { var error = new CouchError(couchApi.Settings.Serializer, response); error.ThrowDatabaseMissingExceptionIfNedded(uriConstructor); if (response.StatusCode == HttpStatusCode.NotFound) return null; error.ThrowCouchCommunicationException(); } var content = response.Content; var mediaType = content.Headers.ContentType != null? content.Headers.ContentType.MediaType: "<unknown>"; switch (mediaType) { case MediaType.Json: return ReadDocument( databaseApi, await content.ReadAsUtf8TextReaderAsync() ); case MediaType.Multipart: return await ReadMultipart(databaseApi, content); default: throw new CouchCommunicationException( "Unexpected media type response recived requesting CouchDB document: {0}", mediaType); } }
/// <constructor /> public BulkUpdateBatch(DbUriConstructor uriConstructor, ISerializer serializer) { this.uriConstructor = uriConstructor; this.serializer = serializer; }
public void ThrowDatabaseMissingExceptionIfNedded(DbUriConstructor uriConstructor) { ThrowDatabaseMissingExceptionIfNedded(uriConstructor.DatabaseName); }
/// <constructor /> public BulkUpdateBatch(DbUriConstructor uriConstructor, ISerializer serializer) { this.uriConstructor = uriConstructor; this.serializer = serializer; }
public void ThrowDatabaseMissingExceptionIfNedded(DbUriConstructor uriConstructor) { ThrowDatabaseMissingExceptionIfNedded(uriConstructor.DatabaseName); }