public override CosmosFeedResultSetIterator GetItemStreamIterator(
     int?maxItemCount         = null,
     string continuationToken = null,
     CosmosItemRequestOptions requestOptions = null)
 {
     return(new CosmosFeedResultSetIteratorCore(maxItemCount, continuationToken, requestOptions, this.ItemStreamFeedRequestExecutor));
 }
        public override Task <CosmosItemResponse <T> > ReadItemAsync <T>(
            object partitionKey,
            string id,
            CosmosItemRequestOptions requestOptions = null,
            CancellationToken cancellationToken     = default(CancellationToken))
        {
            Task <CosmosResponseMessage> response = this.ReadItemStreamAsync(
                partitionKey: partitionKey,
                id: id,
                requestOptions: requestOptions,
                cancellationToken: cancellationToken);

            return(this.clientContext.ResponseFactory.CreateItemResponse <T>(response));
        }
 public override Task <CosmosResponseMessage> ReadItemStreamAsync(
     object partitionKey,
     string id,
     CosmosItemRequestOptions requestOptions = null,
     CancellationToken cancellationToken     = default(CancellationToken))
 {
     return(this.ProcessItemStreamAsync(
                partitionKey,
                id,
                null,
                OperationType.Read,
                requestOptions,
                cancellationToken));
 }
        public override Task <CosmosItemResponse <T> > CreateItemAsync <T>(
            object partitionKey,
            T item,
            CosmosItemRequestOptions requestOptions = null,
            CancellationToken cancellationToken     = default(CancellationToken))
        {
            Task <CosmosResponseMessage> response = this.CreateItemStreamAsync(
                partitionKey: partitionKey,
                streamPayload: this.clientContext.JsonSerializer.ToStream <T>(item),
                requestOptions: requestOptions,
                cancellationToken: cancellationToken);

            return(this.clientContext.ResponseFactory.CreateItemResponse <T>(response));
        }
 public override Task <CosmosResponseMessage> CreateItemStreamAsync(
     object partitionKey,
     Stream streamPayload,
     CosmosItemRequestOptions requestOptions = null,
     CancellationToken cancellationToken     = default(CancellationToken))
 {
     return(this.ProcessItemStreamAsync(
                partitionKey,
                null,
                streamPayload,
                OperationType.Create,
                requestOptions,
                cancellationToken));
 }
 /// <summary>
 /// Creates a Item as an asynchronous operation in the Azure Cosmos service.
 /// </summary>
 /// <param name="partitionKey">The partition key for the item. <see cref="Microsoft.Azure.Documents.PartitionKey"/></param>
 /// <param name="streamPayload">A <see cref="Stream"/> containing the payload.</param>
 /// <param name="requestOptions">(Optional) The options for the item request <see cref="CosmosItemRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>The <see cref="CosmosResponseMessage"/> that was created contained within a <see cref="System.Threading.Tasks.Task"/> object representing the service response for the asynchronous operation.</returns>
 /// <exception>
 /// The Stream operation only throws on client side exceptions. This is to increase performance and prevent the overhead of throwing exceptions. Check the HTTP status code on the response to check if the operation failed.
 /// </exception>
 /// <example>
 /// This example creates an item in a Cosmos container.
 /// <code language="c#">
 /// <![CDATA[
 /// //Create the object in Cosmos
 /// using (CosmosResponseMessage response = await this.Container.Items.CreateItemStreamAsync(partitionKey: "streamPartitionKey", streamPayload: stream))
 /// {
 ///     if (!response.IsSuccessStatusCode)
 ///     {
 ///         //Handle and log exception
 ///         return;
 ///     }
 ///
 ///     using (Stream responseStream = await response.ReadBodyAsync())
 ///     {
 ///         //Read or do other operations with the stream
 ///         using (StreamReader streamReader = new StreamReader(responseStream))
 ///         {
 ///             string responseContentAsString = await streamReader.ReadToEndAsync();
 ///         }
 ///     }
 /// }
 /// ]]>
 /// </code>
 /// </example>
 public abstract Task <CosmosResponseMessage> CreateItemStreamAsync(
     object partitionKey,
     Stream streamPayload,
     CosmosItemRequestOptions requestOptions = null,
     CancellationToken cancellationToken     = default(CancellationToken));
 /// <summary>
 /// Gets an iterator to go through all the items for the container as the original CosmosResponseMessage
 /// </summary>
 /// <param name="maxItemCount">(Optional) The max item count to return as part of the query</param>
 /// <param name="continuationToken">(Optional) The continuation token in the Azure Cosmos DB service.</param>
 /// <param name="requestOptions">(Optional) The options for the item query request <see cref="CosmosQueryRequestOptions"/></param>
 /// <example>
 /// Get an iterator for all the items under the cosmos container
 /// <code language="c#">
 /// <![CDATA[
 /// public class ToDoActivity{
 ///     public string id {get; set;}
 ///     public string status {get; set;}
 /// }
 ///
 /// CosmosResultSetIterator setIterator = this.Container.Items.GetItemStreamIterator();
 /// while (setIterator.HasMoreResults)
 /// {
 ///     using (CosmosResponseMessage iterator = await setIterator.FetchNextSetAsync())
 ///     {
 ///         using (StreamReader sr = new StreamReader(iterator.Content))
 ///         {
 ///             string content = await sr.ReadToEndAsync();
 ///         }
 ///     }
 /// }
 /// ]]>
 /// </code>
 /// </example>
 public abstract CosmosFeedResultSetIterator GetItemStreamIterator(
     int?maxItemCount         = null,
     string continuationToken = null,
     CosmosItemRequestOptions requestOptions = null);
 /// <summary>
 /// Delete a item from the Azure Cosmos service as an asynchronous operation.
 /// </summary>
 /// <param name="partitionKey">The partition key for the item. <see cref="Microsoft.Azure.Documents.PartitionKey"/></param>
 /// <param name="id">The cosmos item id</param>
 /// <param name="requestOptions">(Optional) The options for the item request <see cref="CosmosItemRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>A <see cref="Task"/> containing a <see cref="CosmosItemResponse{T}"/> which will contain information about the request issued.</returns>
 /// <exception cref="CosmosException">
 /// This exception can encapsulate many different types of errors. To determine the specific error always look at the StatusCode property. Some common codes you may get when creating a Document are:
 /// <list type="table">
 ///     <listheader>
 ///         <term>StatusCode</term><description>Reason for exception</description>
 ///     </listheader>
 ///     <item>
 ///         <term>429</term><description>TooManyRequests - This means you have exceeded the number of request units per second.</description>
 ///     </item>
 /// </list>
 /// </exception>
 /// <example>
 /// <code language="c#">
 /// <![CDATA[
 /// public class ToDoActivity{
 ///     public string id {get; set;}
 ///     public string status {get; set;}
 /// }
 ///
 /// CosmosItemResponse item = await this.cosmosContainer.Items.DeleteItemAsync<ToDoActivity>("partitionKey", "id");
 /// ]]>
 /// </code>
 /// </example>
 public abstract Task <CosmosItemResponse <T> > DeleteItemAsync <T>(
     object partitionKey,
     string id,
     CosmosItemRequestOptions requestOptions = null,
     CancellationToken cancellationToken     = default(CancellationToken));
 /// <summary>
 /// Upserts an item as an asynchronous operation in the Azure Cosmos service.
 /// </summary>
 /// <param name="partitionKey">The partition key for the item. <see cref="Microsoft.Azure.Documents.PartitionKey"/></param>
 /// <param name="item">A JSON serializable object that must contain an id property. <see cref="CosmosJsonSerializer"/> to implement a custom serializer</param>
 /// <param name="requestOptions">(Optional) The options for the item request <see cref="CosmosItemRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>The <see cref="CosmosItemResponse{T}"/> that was upserted contained within a <see cref="System.Threading.Tasks.Task"/> object representing the service response for the asynchronous operation.</returns>
 /// <exception cref="System.AggregateException">Represents a consolidation of failures that occurred during async processing. Look within InnerExceptions to find the actual exception(s)</exception>
 /// <exception cref="CosmosException">This exception can encapsulate many different types of errors. To determine the specific error always look at the StatusCode property. Some common codes you may get when creating a Document are:
 /// <list type="table">
 ///     <listheader>
 ///         <term>StatusCode</term><description>Reason for exception</description>
 ///     </listheader>
 ///     <item>
 ///         <term>400</term><description>BadRequest - This means something was wrong with the document supplied.</description>
 ///     </item>
 ///     <item>
 ///         <term>403</term><description>Forbidden - This likely means the collection in to which you were trying to upsert the document is full.</description>
 ///     </item>
 ///     <item>
 ///         <term>413</term><description>RequestEntityTooLarge - This means the item exceeds the current max entity size. Consult documentation for limits and quotas.</description>
 ///     </item>
 ///     <item>
 ///         <term>429</term><description>TooManyRequests - This means you have exceeded the number of request units per second. Consult the DocumentClientException.RetryAfter value to see how long you should wait before retrying this operation.</description>
 ///     </item>
 /// </list>
 /// </exception>
 /// <example>
 /// <code language="c#">
 /// <![CDATA[
 /// public class ToDoActivity{
 ///     public string id {get; set;}
 ///     public string status {get; set;}
 /// }
 ///
 /// ToDoActivity test = new ToDoActivity()
 /// {
 ///    id = Guid.NewGuid().ToString(),
 ///    status = "InProgress"
 /// };
 ///
 /// CosmosItemResponse<ToDoActivity> item = await this.cosmosContainer.Items.UpsertAsync<ToDoActivity>(test.status, test);
 /// ]]>
 /// </code>
 /// </example>
 public abstract Task <CosmosItemResponse <T> > UpsertItemAsync <T>(
     object partitionKey,
     T item,
     CosmosItemRequestOptions requestOptions = null,
     CancellationToken cancellationToken     = default(CancellationToken));
 /// <summary>
 /// Reads a item from the Azure Cosmos service as an asynchronous operation.
 /// </summary>
 /// <param name="partitionKey">The partition key for the item. <see cref="Microsoft.Azure.Documents.PartitionKey"/></param>
 /// <param name="id">The cosmos item id</param>
 /// <param name="requestOptions">(Optional) The options for the item request <see cref="CosmosItemRequestOptions"/></param>
 /// <param name="cancellationToken">(Optional) <see cref="CancellationToken"/> representing request cancellation.</param>
 /// <returns>
 /// A <see cref="Task"/> containing a <see cref="CosmosResponseMessage"/> which wraps a <see cref="Stream"/> containing the read resource record.
 /// </returns>
 /// <exception>
 /// The Stream operation only throws on client side exceptions. This is to increase performance and prevent the overhead of throwing exceptions. Check the HTTP status code on the response to check if the operation failed.
 /// </exception>
 /// <example>
 /// Read a response as a stream.
 /// <code language="c#">
 /// <![CDATA[
 /// using(CosmosResponseMessage response = this.cosmosContainer.Items.ReadItemStreamAsync("partitionKey", "id"))
 /// {
 ///     if (!response.IsSuccessStatusCode)
 ///     {
 ///         //Handle and log exception
 ///         return;
 ///     }
 ///
 ///     using(Stream stream = response.ReadBodyAsync())
 ///     {
 ///         //Read or do other operations with the stream
 ///         using (StreamReader streamReader = new StreamReader(stream))
 ///         {
 ///             string content =  streamReader.ReadToEndAsync();
 ///         }
 ///     }
 /// }
 ///
 /// ]]>
 /// </code>
 /// </example>
 public abstract Task <CosmosResponseMessage> ReadItemStreamAsync(
     object partitionKey,
     string id,
     CosmosItemRequestOptions requestOptions = null,
     CancellationToken cancellationToken     = default(CancellationToken));