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


C# HttpRouteCollection.MapODataRoute方法代码示例

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


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

示例1: MapODataRoute_Returns_ODataRoute

        public void MapODataRoute_Returns_ODataRoute()
        {
            // Arrange
            HttpRouteCollection routes = new HttpRouteCollection();
            IEdmModel model = new EdmModel();

            // Act
            ODataRoute route = routes.MapODataRoute("odata", "odata", model);

            // Assert
            Assert.NotNull(route);
            Assert.Same(model, route.PathRouteConstraint.EdmModel);
            Assert.Equal("odata", route.PathRouteConstraint.RouteName);
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:14,代码来源:ODataHttpRouteCollectionExtensionsTest.cs

示例2: MapODataRoute_AddsBatchRoute_WhenBatchHandlerIsProvided

        public void MapODataRoute_AddsBatchRoute_WhenBatchHandlerIsProvided()
        {
            HttpRouteCollection routes = new HttpRouteCollection();
            IEdmModel model = new EdmModel();
            string routeName = "name";
            string routePrefix = "prefix";

            var batchHandler = new DefaultODataBatchHandler(new HttpServer());
            routes.MapODataRoute(routeName, routePrefix, model, batchHandler);

            IHttpRoute batchRoute = routes["nameBatch"];
            Assert.NotNull(batchRoute);
            Assert.Same(batchHandler, batchRoute.Handler);
            Assert.Equal("prefix/$batch", batchRoute.RouteTemplate);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:15,代码来源:ODataHttpRouteCollectionExtensionsTest.cs

示例3: MapODataRoute_ConfiguresARoute_WithAnODataRouteConstraint

        public void MapODataRoute_ConfiguresARoute_WithAnODataRouteConstraint()
        {
            HttpRouteCollection routes = new HttpRouteCollection();
            IEdmModel model = new EdmModel();
            string routeName = "name";
            string routePrefix = "prefix";

            routes.MapODataRoute(routeName, routePrefix, model);

            IHttpRoute odataRoute = routes[routeName];
            Assert.Single(routes);
            Assert.Equal(routePrefix + "/{*odataPath}", odataRoute.RouteTemplate);
            var constraint = Assert.Single(odataRoute.Constraints);
            var odataConstraint = Assert.IsType<ODataPathRouteConstraint>(constraint.Value);
            Assert.Same(model, odataConstraint.EdmModel);
            Assert.IsType<DefaultODataPathHandler>(odataConstraint.PathHandler);
            Assert.IsType<List<IODataRoutingConvention>>(odataConstraint.RoutingConventions);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:18,代码来源:ODataHttpRouteCollectionExtensionsTest.cs


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