コード例 #1
0
ファイル: UpdatedODataResult.cs プロジェクト: bdebaere/WebApi
        /// <inheritdoc/>
        public virtual async Task <HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
        {
            IHttpActionResult result = GetInnerActionResult();
            var response             = await result.ExecuteAsync(cancellationToken);

            ResultHelpers.AddServiceVersion(response, () => ODataUtils.ODataVersionToString(ResultHelpers.GetODataResponseVersion(Request)));
            return(response);
        }
コード例 #2
0
        /// <inheritdoc/>
        public async virtual Task ExecuteResultAsync(ActionContext context)
        {
            HttpResponse  response = context.HttpContext.Response;
            HttpRequest   request  = context.HttpContext.Request;
            IActionResult result   = GetInnerActionResult(request);
            await result.ExecuteResultAsync(context);

            ResultHelpers.AddServiceVersion(response, () => ODataUtils.ODataVersionToString(ResultHelpers.GetODataResponseVersion(request)));
        }
コード例 #3
0
        /// <inheritdoc/>
        public virtual async Task <HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
        {
            IHttpActionResult   result   = GetInnerActionResult(Request);
            HttpResponseMessage response = await result.ExecuteAsync(cancellationToken);

            response.Headers.Location = LocationHeader;
            ResultHelpers.AddEntityId(response, () => GenerateEntityId(Request));
            ResultHelpers.AddServiceVersion(response, () => ResultHelpers.GetVersionString(Request));
            return(response);
        }
コード例 #4
0
        /// <inheritdoc/>
        public async virtual Task ExecuteResultAsync(ActionContext context)
        {
            HttpRequest   request  = context.HttpContext.Request;
            HttpResponse  response = context.HttpContext.Response;
            IActionResult result   = GetInnerActionResult(request);
            Uri           location = GenerateLocationHeader(request);

            response.Headers["Location"] = location.AbsoluteUri;
            // Since AddEntityId relies on the response, make sure to execute the result
            // before calling AddEntityId() to ensure the response code is set correctly.
            await result.ExecuteResultAsync(context);

            ResultHelpers.AddEntityId(response, () => GenerateEntityId(request));
            ResultHelpers.AddServiceVersion(response, () => ODataUtils.ODataVersionToString(ResultHelpers.GetODataResponseVersion(request)));
        }