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


C# HttpRouteCollection.MapODataServiceRoute方法代码示例

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


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

示例1: AdvancedMapODataServiceRoute_ConfiguresARoute_WithAnODataRouteConstraintAndVersionConstraints

        public void AdvancedMapODataServiceRoute_ConfiguresARoute_WithAnODataRouteConstraintAndVersionConstraints()
        {
            // Arrange
            HttpRouteCollection routes = new HttpRouteCollection();
            IEdmModel model = new EdmModel();
            string routeName = "name";
            string routePrefix = "prefix";
            var pathHandler = new DefaultODataPathHandler();
            var conventions = new List<IODataRoutingConvention>();

            // Act
            routes.MapODataServiceRoute(routeName, routePrefix, model, pathHandler, conventions);

            // Assert
            IHttpRoute odataRoute = routes[routeName];
            Assert.Single(routes);
            Assert.Equal(routePrefix + "/{*odataPath}", odataRoute.RouteTemplate);
            Assert.Equal(2, odataRoute.Constraints.Count);

            var odataPathConstraint = Assert.Single(odataRoute.Constraints.Values.OfType<ODataPathRouteConstraint>());
            Assert.Same(model, odataPathConstraint.EdmModel);
            Assert.IsType<DefaultODataPathHandler>(odataPathConstraint.PathHandler);
            Assert.NotNull(odataPathConstraint.RoutingConventions);

            var odataVersionConstraint = Assert.Single(odataRoute.Constraints.Values.OfType<ODataVersionConstraint>());
            Assert.Equal(ODataVersion.V1, odataVersionConstraint.MinVersion);
            Assert.Equal(ODataVersion.V3, odataVersionConstraint.MaxVersion);
        }
开发者ID:shailendra9,项目名称:WebApi,代码行数:28,代码来源:HttpRouteCollectionExtensionsTest.cs

示例2: MapODataRoute_Returns_ODataRoute

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

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

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

示例3: MapODataServiceRoute_AddsBatchRoute_WhenBatchHandlerIsProvided

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

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

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

示例4: MapODataServiceRoute_ConfiguresARoute_WithAnODataRouteConstraint

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

            routes.MapODataServiceRoute(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:tlycken,项目名称:aspnetwebstack,代码行数:18,代码来源:HttpRouteCollectionExtensionsTest.cs

示例5: ConfigureODataRoutes

		/// <summary>
		/// Configure the OData routes to use the functionality provided in this library.
		/// </summary>
		/// <param name="routes"></param>
		/// <param name="routeName"></param>
		/// <param name="routePrefix"></param>
		/// <param name="httpServer">A web API <see cref="HttpServer"/> instance.</param>
		/// <param name="edmModel">An <see cref="IEdmModel"/>, to override the EDM model that would be created by <see cref="ContainerMetadata"/>.</param>
		/// <param name="maxOperationsPerChangeset"></param>
		public void ConfigureODataRoutes(HttpRouteCollection routes, string routeName, string routePrefix, HttpServer httpServer, IEdmModel edmModel = null, int? maxOperationsPerChangeset = null)
		{
			Contract.Requires<ArgumentNullException>(routes != null);
			Contract.Requires<ArgumentException>(! string.IsNullOrWhiteSpace(routeName));
			Contract.Requires<ArgumentNullException>(routePrefix != null);
			Contract.Requires<ArgumentNullException>(httpServer != null);
			
			var batchHandler = new ODataServerBatchHandler(httpServer);

		    if (maxOperationsPerChangeset != null)
		    {
		        batchHandler.MessageQuotas.MaxOperationsPerChangeset = maxOperationsPerChangeset.GetValueOrDefault();
		    }

		    routes.MapODataServiceRoute(routeName,
			                            routePrefix,
										edmModel ?? BuildEdmModel(), //_containerMetadata.EdmModel,
			                            new DefaultODataPathHandler(),
			                            GetRoutingConventions(),
			                            batchHandler);
		}
开发者ID:mdabbagh88,项目名称:ODataServer,代码行数:30,代码来源:ODataServerConfigurer.cs


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