示例#1
0
        private async Task ExecuteAsync(HttpContext httpContext, StatefulServiceContext serviceContext, IReliableStateManager stateManager)
        {
            // Read the body.
            var    reader  = new StreamReader(httpContext.Request.Body, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true);
            string content = await reader.ReadToEndAsync().ConfigureAwait(false);

            var operations = JsonConvert.DeserializeObject <EntityOperation <JToken, JToken>[]>(content);

            // Update the reliable collections.
            var results = await stateManager.ExecuteAsync(operations).ConfigureAwait(false);

            httpContext.Response.ContentType = "application/json";
            httpContext.Response.StatusCode  = (int)HttpStatusCode.OK;

            // Write the response.
            var response = JsonConvert.SerializeObject(results);
            await httpContext.Response.WriteAsync(response).ConfigureAwait(false);
        }