当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestMessage.SetConfiguration方法代码示例

本文整理汇总了C#中System.Net.Http.HttpRequestMessage.SetConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestMessage.SetConfiguration方法的具体用法?C# HttpRequestMessage.SetConfiguration怎么用?C# HttpRequestMessage.SetConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Http.HttpRequestMessage的用法示例。


在下文中一共展示了HttpRequestMessage.SetConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Match_UsesODataDefaultRoutingConventions_IfControllerFound

        public void Match_UsesODataDefaultRoutingConventions_IfControllerFound(string expectedControllerName,
            string entitySetName)
        {
            // Arrange
            const string routeName = "api";
            var request = new HttpRequestMessage(HttpMethod.Get, "http://any/" + entitySetName);
            var routeCollection = new HttpRouteCollection { { routeName, new HttpRoute() } };
            var config = new HttpConfiguration(routeCollection);
            request.SetConfiguration(config);
            var pathHandler = new DefaultODataPathHandler();
            var model = GetEdmModel();
            config.MapHttpAttributeRoutes();
            var conventions = config.CreateODataDomainRoutingConventions<NorthwindDomainController>(model);
            var constraint = new DefaultODataPathRouteConstraint(pathHandler, model, routeName, conventions);
            config.EnsureInitialized();
            var values = new Dictionary<string, object>
            {
                { ODataRouteConstants.ODataPath, entitySetName },
            };

            // Act
            var matched = constraint.Match(request, route: null, parameterName: null, values: values,
                routeDirection: HttpRouteDirection.UriResolution);

            // Assert
            Assert.True(matched);
            Assert.Equal(expectedControllerName, values[ODataRouteConstants.Controller]);
        }
开发者ID:workjie,项目名称:RESTier,代码行数:28,代码来源:DefaultODataPathRouteConstraintTest.cs

示例2: GenerateActionLink_GeneratesLinkWithCast_IfEntitySetTypeDoesnotMatchActionEntityType

        public void GenerateActionLink_GeneratesLinkWithCast_IfEntitySetTypeDoesnotMatchActionEntityType()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            var vehicles = builder.EntitySet<Vehicle>("vehicles");
            var car = builder.Entity<Car>();
            var paintAction = car.Action("Paint");

            IEdmModel model = builder.GetEdmModel();
            var vehiclesEdmSet = model.EntityContainers().Single().FindEntitySet("vehicles");
            var carEdmType = model.FindDeclaredType("System.Web.Http.OData.Builder.TestModels.Car") as IEdmEntityType;

            HttpConfiguration configuration = new HttpConfiguration();
            string routeName = "Route";
            configuration.Routes.MapODataRoute(routeName, null, model);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost");
            request.SetConfiguration(configuration);
            request.SetODataRouteName(routeName);

            var serializerContext = new ODataSerializerContext { Model = model, EntitySet = vehiclesEdmSet, Url = request.GetUrlHelper() };
            var entityContext = new EntityInstanceContext(serializerContext, carEdmType.AsReference(), new Car { Model = 2009, Name = "Accord" });

            Uri link = ActionLinkGenerationConvention.GenerateActionLink(entityContext, paintAction);

            Assert.Equal("http://localhost/vehicles(Model=2009,Name='Accord')/System.Web.Http.OData.Builder.TestModels.Car/Paint", link.AbsoluteUri);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:26,代码来源:ActionLinkGenerationConventionTest.cs

示例3: GetCorsPolicyProvider_Preflight_ReturnsCompleteControllerContext

        public void GetCorsPolicyProvider_Preflight_ReturnsCompleteControllerContext()
        {
           // Arrange
            AttributeBasedPolicyProviderFactory providerFactory = new AttributeBasedPolicyProviderFactory();
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Options, "http://localhost/sample");
            request.Headers.Add("Origin", "http://localhost");
            request.Headers.Add(CorsConstants.AccessControlRequestMethod, "POST");
            HttpConfiguration config = new HttpConfiguration();
            HttpControllerContext controllerContext = null;
            var actionSelector = new Mock<IHttpActionSelector>();
            actionSelector.Setup(s => s.SelectAction(It.IsAny<HttpControllerContext>()))
                          .Callback<HttpControllerContext>(context => controllerContext = context);
            config.Services.Replace(typeof(IHttpActionSelector), actionSelector.Object);
            request.SetConfiguration(config);
            IHttpRoute route = config.Routes.MapHttpRoute("default", "{controller}/{id}", new { id = RouteParameter.Optional });
            request.SetRouteData(route.GetRouteData("/", request));

            ICorsPolicyProvider provider = providerFactory.GetCorsPolicyProvider(request);
                                      
            // Assert
            Assert.NotNull(controllerContext);
            Assert.Equal(config, controllerContext.Configuration);
            Assert.NotNull(controllerContext.Request);
            Assert.NotNull(controllerContext.RequestContext);
            Assert.NotNull(controllerContext.Controller);
            Assert.NotNull(controllerContext.ControllerDescriptor);
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:27,代码来源:AttributeBasedPolicyProviderFactoryTest.cs

示例4: HandleRequestAsync

        public async Task<HttpResponseMessage> HandleRequestAsync(FunctionDescriptor function, HttpRequestMessage request, Func<HttpRequestMessage, Task<HttpResponseMessage>> invokeFunction)
        {
            // First check if there is a registered WebHook Receiver for this request, and if
            // so use it
            HttpTriggerBindingMetadata httpFunctionMetadata = (HttpTriggerBindingMetadata)function.Metadata.InputBindings.FirstOrDefault(p => p.Type == BindingType.HttpTrigger);
            string webHookReceiver = httpFunctionMetadata.WebHookType;
            IWebHookReceiver receiver = null;
            if (string.IsNullOrEmpty(webHookReceiver) || !_receiverLookup.TryGetValue(webHookReceiver, out receiver))
            {
                // The function is not correctly configured. Log an error and return 500
                string configurationError = string.Format(CultureInfo.InvariantCulture, "Invalid WebHook configuration. Unable to find a receiver for WebHook type '{0}'", webHookReceiver);
                function.Invoker.OnError(new FunctionInvocationException(configurationError));

                return new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
            }

            HttpRequestContext context = new HttpRequestContext
            {
                Configuration = _httpConfiguration
            };
            request.SetConfiguration(_httpConfiguration);

            // add the anonymous handler function from above to the request properties
            // so our custom WebHookHandler can invoke it at the right time
            request.Properties.Add(AzureFunctionsCallbackKey, invokeFunction);

            // Request content can't be read multiple
            // times, so this forces it to buffer
            await request.Content.LoadIntoBufferAsync();

            string receiverId = function.Name.ToLowerInvariant();
            return await receiver.ReceiveAsync(receiverId, context, request);
        }
开发者ID:isaacabraham,项目名称:azure-webjobs-sdk-script,代码行数:33,代码来源:WebHookReceiverManager.cs

示例5: Convention_GeneratesUri_ForActionBoundToEntity

        public void Convention_GeneratesUri_ForActionBoundToEntity()
        {
            // Arrange
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            builder.EntitySet<Customer>("Customers");
            var action = builder.EntityType<Customer>().Action("MyAction");
            action.Parameter<string>("param");
            IEdmModel model = builder.GetEdmModel();

            // Act
            HttpConfiguration configuration = new HttpConfiguration();
            configuration.MapODataServiceRoute("odata", "odata", model);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:123");
            request.SetConfiguration(configuration);
            request.ODataProperties().RouteName = "odata";

            IEdmEntitySet customers = model.EntityContainer.FindEntitySet("Customers");
            var edmType = model.SchemaElements.OfType<IEdmEntityType>().First(e => e.Name == "Customer");
            var serializerContext = new ODataSerializerContext { Model = model, NavigationSource = customers, Url = request.GetUrlHelper() };
            var entityContext = new EntityInstanceContext(serializerContext, edmType.AsReference(), new Customer { Id = 109 });

            // Assert
            var edmAction = model.SchemaElements.OfType<IEdmAction>().First(f => f.Name == "MyAction");
            Assert.NotNull(edmAction);

            ActionLinkBuilder actionLinkBuilder = model.GetActionLinkBuilder(edmAction);
            Uri link = actionLinkBuilder.BuildActionLink(entityContext);

            Assert.Equal("http://localhost:123/odata/Customers(109)/Default.MyAction", link.AbsoluteUri);
        }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:31,代码来源:ActionLinkGenerationConventionTest.cs

示例6: HandleRequestAsync

        public async Task<HttpResponseMessage> HandleRequestAsync(FunctionDescriptor function, HttpRequestMessage request, Func<HttpRequestMessage, Task<HttpResponseMessage>> invokeFunction)
        {
            // First check if there is a registered WebHook Receiver for this request, and if
            // so use it
            HttpBindingMetadata httpFunctionMetadata = (HttpBindingMetadata)function.Metadata.InputBindings.FirstOrDefault(p => p.Type == BindingType.HttpTrigger);
            string webHookReceiver = httpFunctionMetadata.WebHookType;
            IWebHookReceiver receiver = null;
            if (string.IsNullOrEmpty(webHookReceiver) || !_receiverLookup.TryGetValue(webHookReceiver, out receiver))
            {
                // If the function is a not a correctly configured WebHook return 500
                return new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
            }

            HttpRequestContext context = new HttpRequestContext
            {
                Configuration = _httpConfiguration
            };
            request.SetConfiguration(_httpConfiguration);

            // add the anonymous handler function from above to the request properties
            // so our custom WebHookHandler can invoke it at the right time
            request.Properties.Add(AzureFunctionsCallbackKey, invokeFunction);

            // TODO: Is there a better way? Requests content can't be read multiple
            // times, so this forces it to buffer
            await request.Content.ReadAsStringAsync();

            string receiverId = function.Name.ToLowerInvariant();
            return await receiver.ReceiveAsync(receiverId, context, request);
        }
开发者ID:cmatskas,项目名称:azure-webjobs-sdk-script,代码行数:30,代码来源:WebHookReceiverManager.cs

示例7: Apply_Doesnot_Override_UserConfiguration

        public void Apply_Doesnot_Override_UserConfiguration()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            var vehicles = builder.EntitySet<Vehicle>("vehicles");
            var car = builder.AddEntityType(typeof(Car));
            var paintAction = vehicles.EntityType.Action("Paint");
            paintAction.HasActionLink(ctxt => new Uri("http://localhost/ActionTestWorks"), followsConventions: false);
            ActionLinkGenerationConvention convention = new ActionLinkGenerationConvention();

            convention.Apply(paintAction, builder);

            IEdmModel model = builder.GetEdmModel();
            var vehiclesEdmSet = model.EntityContainer.FindEntitySet("vehicles");
            var carEdmType = model.FindDeclaredType("System.Web.OData.Builder.TestModels.Car") as IEdmEntityType;
            var paintEdmAction =
                model.GetAvailableProcedures(
                    model.FindDeclaredType("System.Web.OData.Builder.TestModels.Car") as IEdmEntityType).Single()
                as IEdmAction;
            Assert.NotNull(paintEdmAction);

            HttpConfiguration configuration = new HttpConfiguration();
            configuration.Routes.MapODataServiceRoute(model);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost");
            request.SetConfiguration(configuration);

            ActionLinkBuilder actionLinkBuilder = model.GetActionLinkBuilder(paintEdmAction);

            var serializerContext = new ODataSerializerContext { Model = model, NavigationSource = vehiclesEdmSet, Url = request.GetUrlHelper() };
            var entityContext = new EntityInstanceContext(serializerContext, carEdmType.AsReference(), new Car { Model = 2009, Name = "Contoso" });

            Uri link = actionLinkBuilder.BuildActionLink(entityContext);
            Assert.Equal("http://localhost/ActionTestWorks", link.AbsoluteUri);
        }
开发者ID:nicholaspei,项目名称:aspnetwebstack,代码行数:34,代码来源:ActionLinkGenerationConventionTest.cs

示例8: NavigationLinksGenerationConvention_GeneratesLinksWithCast_ForDerivedProperties

        public void NavigationLinksGenerationConvention_GeneratesLinksWithCast_ForDerivedProperties()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            builder.EntitySet<Vehicle>("vehicles");
            builder.EntitySet<Manufacturer>("manufacturers");

            IEdmModel model = builder.GetEdmModel();
            IEdmEntitySet vehiclesEdmEntitySet = model.EntityContainer.FindEntitySet("vehicles");
            IEdmEntityType carType = model.AssertHasEntityType(typeof(Car));
            IEdmNavigationProperty carManufacturerProperty = carType.AssertHasNavigationProperty(model, "Manufacturer", typeof(CarManufacturer), isNullable: true, multiplicity: EdmMultiplicity.ZeroOrOne);

            HttpConfiguration configuration = new HttpConfiguration();
            string routeName = "Route";
            configuration.Routes.MapODataServiceRoute(routeName, null, model);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost");
            request.SetConfiguration(configuration);
            request.ODataProperties().RouteName = routeName;

            NavigationSourceLinkBuilderAnnotation linkBuilder = model.GetNavigationSourceLinkBuilder(vehiclesEdmEntitySet);

            var serializerContext = new ODataSerializerContext { Model = model, NavigationSource = vehiclesEdmEntitySet, Url = request.GetUrlHelper() };
            var entityContext = new EntityInstanceContext(serializerContext, carType.AsReference(), new Car { Model = 2009, Name = "Accord" });

            Uri uri = linkBuilder.BuildNavigationLink(entityContext, carManufacturerProperty, ODataMetadataLevel.Default);

            Assert.Equal("http://localhost/vehicles(Model=2009,Name='Accord')/System.Web.OData.Builder.TestModels.Car/Manufacturer", uri.AbsoluteUri);
        }
开发者ID:nicholaspei,项目名称:aspnetwebstack,代码行数:28,代码来源:NavigationLinksGenerationConventionTest.cs

示例9: GenerateActionLink_GeneratesLinkWithoutCast_IfEntitySetTypeMatchesActionEntityType

        public void GenerateActionLink_GeneratesLinkWithoutCast_IfEntitySetTypeMatchesActionEntityType()
        {
            // Arrange
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            var cars = builder.EntitySet<Car>("cars");
            var paintAction = cars.EntityType.Action("Paint");

            IEdmModel model = builder.GetEdmModel();
            var carsEdmSet = model.EntityContainers().Single().FindEntitySet("cars");

            HttpConfiguration configuration = new HttpConfiguration();
            string routeName = "Route";
            configuration.Routes.MapODataRoute(routeName, null, model);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost");
            request.SetConfiguration(configuration);
            request.SetODataRouteName(routeName);

            // Act
            Uri link = ActionLinkGenerationConvention.GenerateActionLink(
                new EntityInstanceContext()
                {
                    EdmModel = model,
                    EntitySet = carsEdmSet,
                    EntityType = carsEdmSet.ElementType,
                    Url = request.GetUrlHelper(),
                    EntityInstance = new Car { Model = 2009, Name = "Accord" }
                },
                paintAction);

            Assert.Equal("http://localhost/cars(Model=2009,Name='Accord')/Paint", link.AbsoluteUri);
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:32,代码来源:ActionLinkGenerationConventionTest.cs

示例10: CreateHttpRequestMessage

        private static HttpRequestMessage CreateHttpRequestMessage(HttpActionDescriptor actionDescriptor, ODataRoute oDataRoute, HttpConfiguration httpConfig)
        {
            Contract.Requires(httpConfig != null);
            Contract.Requires(oDataRoute != null);
            Contract.Requires(httpConfig != null);
            Contract.Ensures(Contract.Result<HttpRequestMessage>() != null);

            Contract.Assume(oDataRoute.Constraints != null);

            var httpRequestMessage = new HttpRequestMessage(actionDescriptor.SupportedHttpMethods.First(), "http://any/");

            var requestContext = new HttpRequestContext
            {
                Configuration = httpConfig
            };
            httpRequestMessage.SetConfiguration(httpConfig);
            httpRequestMessage.SetRequestContext(requestContext);

            var httpRequestMessageProperties = httpRequestMessage.ODataProperties();
            Contract.Assume(httpRequestMessageProperties != null);
            httpRequestMessageProperties.Model = oDataRoute.GetEdmModel();
            httpRequestMessageProperties.RouteName = oDataRoute.GetODataPathRouteConstraint().RouteName;
            httpRequestMessageProperties.RoutingConventions = oDataRoute.GetODataPathRouteConstraint().RoutingConventions;
            httpRequestMessageProperties.PathHandler = oDataRoute.GetODataPathRouteConstraint().PathHandler;
            return httpRequestMessage;
        }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:26,代码来源:AttributeRouteStrategy.cs

示例11: TryHandle

        public async Task<HttpResponseMessage> TryHandle(HttpRequestMessage request, Func<HttpRequestMessage, Task<HttpResponseMessage>> invokeJobFunction)
        {
            // First check if there is a registered WebHook Receiver for this request, and if
            // so use it
            string route = request.RequestUri.LocalPath.ToLowerInvariant();
            IWebHookReceiver receiver = null;
            string receiverId = null;

            if (TryParseReceiver(route, out receiver, out receiverId))
            {
                HttpRequestContext context = new HttpRequestContext
                {
                    Configuration = _httpConfiguration
                };
                request.SetConfiguration(_httpConfiguration);

                // add the anonymous handler function from above to the request properties
                // so our custom WebHookHandler can invoke it at the right time
                request.Properties.Add(WebHookJobFunctionInvokerKey, invokeJobFunction);

                return await receiver.ReceiveAsync(receiverId, context, request);
            }

            return null;
        }
开发者ID:paulbatum,项目名称:azure-webjobs-sdk-extensions,代码行数:25,代码来源:WebHookReceiverManager.cs

示例12: GetHttpActionDescriptorForRestierController

        private static HttpActionDescriptor GetHttpActionDescriptorForRestierController(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor)
        {
            HttpActionDescriptor actionDescriptor;

            var perControllerConfig = controllerDescriptor.Configuration;
            request.SetConfiguration(perControllerConfig);
            var requestContext = request.GetRequestContext();
            requestContext.Configuration = perControllerConfig;
            requestContext.RouteData = request.GetRouteData();
            requestContext.Url = new UrlHelper(request);
            requestContext.VirtualPathRoot = perControllerConfig.VirtualPathRoot;

            var controller = controllerDescriptor.CreateController(request);

            using (controller as IDisposable)
            {
                var controllerContext = new HttpControllerContext(requestContext, request, controllerDescriptor, controller);
                try
                {
                    actionDescriptor = perControllerConfig.Services.GetActionSelector().SelectAction(controllerContext);
                }
                catch (HttpResponseException ex)
                {
                    if (ex.Response.StatusCode == HttpStatusCode.NotFound || ex.Response.StatusCode == HttpStatusCode.MethodNotAllowed)
                    {
                        actionDescriptor = null;
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return actionDescriptor;
        }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:35,代码来源:HttpRequestMessageExtensions.cs

示例13: ProcessBatchAsync_CallsRegisterForDispose

        public void ProcessBatchAsync_CallsRegisterForDispose()
        {
            // Arrange
            List<IDisposable> expectedResourcesForDisposal = new List<IDisposable>();
            MockHttpServer server = new MockHttpServer(request =>
            {
                var tmpContent = new StringContent(String.Empty);
                request.RegisterForDispose(tmpContent);
                expectedResourcesForDisposal.Add(tmpContent);
                return new HttpResponseMessage { Content = new StringContent(request.RequestUri.AbsoluteUri) };
            });
            UnbufferedODataBatchHandler batchHandler = new UnbufferedODataBatchHandler(server);
            HttpRequestMessage batchRequest = new HttpRequestMessage(HttpMethod.Post, "http://example.com/$batch")
            {
                Content = new MultipartContent("mixed")
                {
                    ODataBatchRequestHelper.CreateODataRequestContent(new HttpRequestMessage(HttpMethod.Get, "http://example.com/")),
                    new MultipartContent("mixed") // ChangeSet
                    {
                        ODataBatchRequestHelper.CreateODataRequestContent(new HttpRequestMessage(HttpMethod.Post, "http://example.com/"))
                    }
                }
            };
            batchRequest.SetConfiguration(new HttpConfiguration());

            // Act
            var response = batchHandler.ProcessBatchAsync(batchRequest, CancellationToken.None).Result;
            var resourcesForDisposal = batchRequest.GetResourcesForDisposal();

            // Assert
            foreach (var expectedResource in expectedResourcesForDisposal)
            {
                Assert.Contains(expectedResource, resourcesForDisposal);
            }
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:35,代码来源:UnbufferedODataBatchHandlerTest.cs

示例14: SendAsync_Preflight_ReturnsAllowMethodsAndAllowHeaders

        public void SendAsync_Preflight_ReturnsAllowMethodsAndAllowHeaders(string requestedMethod, string expectedOrigin, string requestedHeaders)
        {
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute("default", "{controller}");
            HttpServer server = new HttpServer(config);
            CorsMessageHandler corsHandler = new CorsMessageHandler(config);
            corsHandler.InnerHandler = server;
            HttpMessageInvoker invoker = new HttpMessageInvoker(corsHandler);
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Options, "http://localhost/sample");
            request.SetConfiguration(config);
            request.Headers.Add(CorsConstants.Origin, "http://localhost");
            request.Headers.Add(CorsConstants.AccessControlRequestMethod, requestedMethod);
            request.Headers.Add(CorsConstants.AccessControlRequestHeaders, requestedHeaders);

            HttpResponseMessage response = invoker.SendAsync(request, CancellationToken.None).Result;
            string origin = response.Headers.GetValues(CorsConstants.AccessControlAllowOrigin).FirstOrDefault();
            string allowMethod = response.Headers.GetValues(CorsConstants.AccessControlAllowMethods).FirstOrDefault();
            string[] allowHeaders = response.Headers.GetValues(CorsConstants.AccessControlAllowHeaders).FirstOrDefault().Split(',');
            string[] requestedHeaderArray = requestedHeaders.Split(',');

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(expectedOrigin, origin);
            Assert.Equal(requestedMethod, allowMethod);
            foreach (string requestedHeader in requestedHeaderArray)
            {
                Assert.Contains(requestedHeader, allowHeaders);
            }
        }
开发者ID:normalian,项目名称:aspnetwebstack,代码行数:28,代码来源:CorsMessageHandlerTest.cs

示例15: GenerateLinkDirectly_ReturnsNull_IfRouteTemplateHasParameterInPrefix

        public void GenerateLinkDirectly_ReturnsNull_IfRouteTemplateHasParameterInPrefix()
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/vpath/prefix/Customers");
            HttpConfiguration config = new HttpConfiguration(new HttpRouteCollection("http://localhost/vpath"));
            request.SetConfiguration(config);
            ODataRoute odataRoute = new ODataRoute("{prefix}", pathConstraint: null);

            Assert.Null(odataRoute.GenerateLinkDirectly(request, "odataPath"));
        }
开发者ID:shailendra9,项目名称:WebApi,代码行数:9,代码来源:ODataRouteTest.cs


注:本文中的System.Net.Http.HttpRequestMessage.SetConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。