Exemplo n.º 1
0
        private void Initialize(ODataOptions options)
        {
            Contract.Assert(options != null);

            foreach (var model in options.Models)
            {
                IServiceProvider subServiceProvider = model.Value.Item2;
                if (subServiceProvider == null)
                {
                    continue;
                }

                // If a batch handler is present, register the route with the batch path mapper. This will be used
                // by the batching middleware to handle the batch request. Batching still requires the injection
                // of the batching middleware via UseODataBatching().
                ODataBatchHandler batchHandler = subServiceProvider.GetService <ODataBatchHandler>();
                if (batchHandler != null)
                {
                    batchHandler.PrefixName = model.Key;
                    string batchPath = string.IsNullOrEmpty(model.Key)  ? "/$batch" : $"/{model.Key}/$batch";

                    if (_batchMapping == null)
                    {
                        _batchMapping = new ODataBatchPathMapping();
                    }

                    _batchMapping.AddRoute(model.Key, batchPath, batchHandler);
                }
            }
        }