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


C# HttpConfiguration.SetEdmModel方法代码示例

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


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

示例1: SetEdmModel_WithADifferentModel_AfterSettingFormatter_Throws

        public void SetEdmModel_WithADifferentModel_AfterSettingFormatter_Throws()
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();
            IEdmModel model = new Mock<IEdmModel>().Object;
            config.SetODataFormatter(new ODataMediaTypeFormatter());

            // Act
            Assert.Throws<NotSupportedException>(
                () => config.SetEdmModel(model),
                "The given 'IEdmModel' does not match the 'IEdmModel' in the formatter on the configuration. Setting 'ODataMediaTypeFormatter' using the method 'SetODataFormatter' also sets the corresponding 'IEdmModel'.");
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:12,代码来源:HttpConfigurationExtensionTests.cs

示例2: GetODataPathHandlerReturnsDefaultPathHandlerByDefault

        public void GetODataPathHandlerReturnsDefaultPathHandlerByDefault()
        {
            HttpConfiguration config = new HttpConfiguration();
            ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
            modelBuilder.EntitySet<Customer>(typeof(Customer).Name);
            IEdmModel model = modelBuilder.GetEdmModel();
            config.SetEdmModel(model);

            var pathHandler = config.GetODataPathHandler();

            Assert.NotNull(pathHandler);
            Assert.IsType<DefaultODataPathHandler>(pathHandler);
        }
开发者ID:Swethach,项目名称:aspnetwebstack,代码行数:13,代码来源:HttpConfigurationExtensionTests.cs

示例3: SetEdmModelThenGetReturnsWhatYouSet

        public void SetEdmModelThenGetReturnsWhatYouSet()
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();
            ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
            modelBuilder.EntitySet<Customer>(typeof(Customer).Name);
            IEdmModel model = modelBuilder.GetEdmModel();

            // Act
            config.SetEdmModel(model);
            IEdmModel newModel = config.GetEdmModel();

            // Assert
            Assert.Same(model, newModel);
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:15,代码来源:HttpConfigurationExtensionTests.cs

示例4: ODataActionTests

        public ODataActionTests()
        {
            _configuration = new HttpConfiguration();
            _model = GetModel();
            _formatter = new ODataMediaTypeFormatter(_model);
            _configuration.Formatters.Clear();
            _configuration.Formatters.Insert(0, _formatter);
            _configuration.SetEdmModel(_model);

            _configuration.Routes.MapHttpRoute("OData", "{*odataPath}", new { controller = "Customers", boundId = "1", id = "1" });
            _configuration.Routes.MapHttpRoute(ODataRouteNames.GetById, "{controller}({id})");
            _configuration.Routes.MapHttpRoute(ODataRouteNames.InvokeBoundAction, "{controller}({boundId})/{odataAction}");
            _configuration.Routes.MapHttpRoute(ODataRouteNames.Metadata, "$metadata");

            _server = new HttpServer(_configuration);
            _client = new HttpClient(_server);
        }
开发者ID:cubski,项目名称:aspnetwebstack,代码行数:17,代码来源:ODataActionTests.cs

示例5: InitializeConfiguration

        private static HttpConfiguration InitializeConfiguration(string controllerName, bool useCustomEdmModel)
        {
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute("default", "{controller}/{id}", new { id = RouteParameter.Optional });

            if (controllerName == "QueryCompositionCustomerGlobal")
            {
                config.Filters.Add(new QueryableAttribute());
            }

            if (useCustomEdmModel)
            {
                ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
                modelBuilder.EntitySet<QueryCompositionCustomer>(typeof(QueryCompositionCustomer).Name);
                IEdmModel model = modelBuilder.GetEdmModel();
                config.SetEdmModel(model);
            }

            return config;
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:20,代码来源:QueryCompositionTests.cs

示例6: GetPostRequest

 private HttpRequestMessage GetPostRequest(string url)
 {
     HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
     HttpConfiguration config = new HttpConfiguration();
     config.SetEdmModel(GetModel());
     IHttpRoute route = new Mock<IHttpRoute>().Object;
     IHttpRouteData routeData = new HttpRouteData(route);
     routeData.Values["odataPath"] = GetODataPath(url);
     request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData;
     request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
     return request;
 }
开发者ID:cubski,项目名称:aspnetwebstack,代码行数:12,代码来源:ODataActionParametersTest.cs

示例7: GetPostRequest

 private HttpRequestMessage GetPostRequest(string url)
 {
     HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
     HttpConfiguration config = new HttpConfiguration();
     IEdmModel model = GetModel();
     config.SetEdmModel(model);
     request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
     IHttpRoute route = new Mock<IHttpRoute>().Object;
     request.Properties["MS_ODataPath"] = new DefaultODataPathHandler(model).Parse(GetODataPath(url));
     return request;
 }
开发者ID:Swethach,项目名称:aspnetwebstack,代码行数:11,代码来源:ODataActionPayloadDeserializerTest.cs


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