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


C# System.Collections.Generic.EnsureInitialized方法代码示例

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


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

示例1: AttributeRouting_QueryProperty_AfterCallBoundFunction

        public async Task AttributeRouting_QueryProperty_AfterCallBoundFunction()
        {
            // Arrange
            const string RequestUri = @"http://localhost/Customers(12)/NS.GetOrder(orderId=4)/Amount";
            CustomersModelWithInheritance model = new CustomersModelWithInheritance();

            HttpConfiguration config = new[] { typeof(CustomersController) }.GetHttpConfiguration();
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
            config.MapODataServiceRoute("odata", "", model.Model);

            HttpServer server = new HttpServer(config);
            config.EnsureInitialized();

            HttpClient client = new HttpClient(server);
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, RequestUri);

            // Act
            HttpResponseMessage response = await client.SendAsync(request);
            string responseString = await response.Content.ReadAsStringAsync();

            // Assert
            Assert.True(response.IsSuccessStatusCode);
            Assert.Equal("{\r\n  \"@odata.context\":\"http://localhost/$metadata#Edm.Int32\",\"value\":56\r\n}",
                responseString);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:25,代码来源:AttributeRoutingTest.cs

示例2: Controller_DoesNotAppear_InApiDescriptions

        public void Controller_DoesNotAppear_InApiDescriptions()
        {
            var config = new[] { typeof(MetadataController) }.GetHttpConfiguration();
            config.Routes.MapHttpRoute("Default", "{controller}/{action}");
            config.MapODataServiceRoute(new ODataConventionModelBuilder().GetEdmModel());
            config.EnsureInitialized();
            var explorer = config.Services.GetApiExplorer();

            var apis = explorer.ApiDescriptions.Select(api => api.ActionDescriptor.ControllerDescriptor.ControllerName);

            Assert.DoesNotContain("ODataMetadata", apis);
        }
开发者ID:shailendra9,项目名称:WebApi,代码行数:12,代码来源:MetadataControllerTest.cs

示例3: AttributeRoutingConvention_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplate

        public void AttributeRoutingConvention_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplate()
        {
            // Arrange
            IEdmModel model = new CustomersModelWithInheritance().Model;
            HttpConfiguration configuration = new[] { typeof(TestODataController) }.GetHttpConfiguration();
            AttributeRoutingConvention convention = new AttributeRoutingConvention(model, configuration);

            // Act & Assert
            Assert.DoesNotThrow(() => configuration.EnsureInitialized());
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:10,代码来源:AttributeRoutingConventionTest.cs

示例4: AttributeRoutingConvention_ConfigEnsureInitialized_ThrowsForInvalidPathTemplate

        public void AttributeRoutingConvention_ConfigEnsureInitialized_ThrowsForInvalidPathTemplate()
        {
            // Arrange
            IEdmModel model = new EdmModel();
            HttpConfiguration configuration = new[] { typeof(TestODataController) }.GetHttpConfiguration();
            AttributeRoutingConvention convention = new AttributeRoutingConvention(model, configuration);

            // Act & Assert
            Assert.Throws<InvalidOperationException>(
                () => configuration.EnsureInitialized(),
                "The path template 'Customers' on the action 'GetCustomers' in controller 'TestOData' is not a valid OData path template. " +
                "The operation import overloads matching 'Customers' are invalid. This is most likely an error in the IEdmModel.");
        }
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:13,代码来源:AttributeRoutingConventionTest.cs

示例5: ODataConventionModelBuilder

        public void MapODataServiceRoute_ConfigEnsureInitialized_DoesNotThrowForInvalidPathTemplateWithoutAttributeRouting()
        {
            // Arrange
            var builder = new ODataConventionModelBuilder();
            builder.EntitySet<Customer>("Customers").EntityType.Ignore(c => c.Name);
            IEdmModel model = builder.GetEdmModel();
            HttpConfiguration configuration = new[] { typeof(CustomersController) }.GetHttpConfiguration();
            configuration.MapODataServiceRoute(
                "RouteName",
                "RoutePrefix",
                model,
                new DefaultODataPathHandler(),
                ODataRoutingConventions.CreateDefault());

            // Act & Assert
            Assert.DoesNotThrow(() => configuration.EnsureInitialized());
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:17,代码来源:HttpRouteCollectionExtensionsTest.cs

示例6: MapODataServiceRoute_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplateWithAttributeRouting

        public void MapODataServiceRoute_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplateWithAttributeRouting()
        {
            // Arrange
            var builder = new ODataConventionModelBuilder();
            builder.EntitySet<Customer>("Customers");
            IEdmModel model = builder.GetEdmModel();
            HttpConfiguration configuration = new[] { typeof(CustomersController) }.GetHttpConfiguration();
            configuration.MapODataServiceRoute(model);

            // Act & Assert
            Assert.DoesNotThrow(() => configuration.EnsureInitialized());
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:12,代码来源:HttpRouteCollectionExtensionsTest.cs


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