Ejemplo n.º 1
0
        /// <summary>
        /// Invoke the OData $Batch middleware.
        /// </summary>
        /// <param name="context">The http context.</param>
        /// <returns>A task that can be awaited.</returns>
        public async Task Invoke(HttpContext context)
        {
            if (context == null)
            {
                throw Error.ArgumentNull(nameof(context));
            }

            string            prefixName;
            ODataBatchHandler batchHandler;

            if (_batchMapping != null && _batchMapping.TryGetPrefixName(context, out prefixName, out batchHandler))
            {
                Contract.Assert(batchHandler != null);
                await batchHandler.ProcessBatchAsync(context, _next).ConfigureAwait(false);
            }
            else
            {
                await _next(context).ConfigureAwait(false);
            }
        }
        /// <summary>
        /// Invoke the OData $Batch middleware.
        /// </summary>
        /// <param name="context">The http context.</param>
        /// <returns>A task that can be awaited.</returns>
        public async Task Invoke(HttpContext context)
        {
            if (context == null)
            {
                throw Error.ArgumentNull(nameof(context));
            }
            string            prefixName;
            ODataBatchHandler batchHandler;

            // The batch middleware should not handle the options requests for cors to properly function.
            bool isPostRequest = HttpMethods.IsPost(context.Request.Method);

            if (isPostRequest &&
                _batchMapping != null &&
                _batchMapping.TryGetPrefixName(context, out prefixName, out batchHandler))
            {
                Contract.Assert(batchHandler != null);
                await batchHandler.ProcessBatchAsync(context, _next).ConfigureAwait(false);
            }
            else
            {
                await _next(context).ConfigureAwait(false);
            }
        }