當前位置: 首頁>>代碼示例>>C#>>正文


C# HttpRequestMessage.GetRoutingConventionsDataStore方法代碼示例

本文整理匯總了C#中System.Net.Http.HttpRequestMessage.GetRoutingConventionsDataStore方法的典型用法代碼示例。如果您正苦於以下問題:C# HttpRequestMessage.GetRoutingConventionsDataStore方法的具體用法?C# HttpRequestMessage.GetRoutingConventionsDataStore怎麽用?C# HttpRequestMessage.GetRoutingConventionsDataStore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Net.Http.HttpRequestMessage的用法示例。


在下文中一共展示了HttpRequestMessage.GetRoutingConventionsDataStore方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetValueProvider_ReturnsValueProvider_BackedByRoutingStore

        public void GetValueProvider_ReturnsValueProvider_BackedByRoutingStore()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();
            request.GetRoutingConventionsDataStore()["ID"] = 42;
            HttpActionContext actionContext = new HttpActionContext { ControllerContext = new HttpControllerContext { Request = request } };
            ODataValueProviderFactory factory = new ODataValueProviderFactory();

            // Act
            var valueProvider = factory.GetValueProvider(actionContext);

            // Assert
            Assert.NotNull(valueProvider);
            Assert.Equal(42, valueProvider.GetValue("ID").RawValue);
        }
開發者ID:quentez,項目名稱:aspnetwebstack,代碼行數:15,代碼來源:ODataValueProviderFactoryTest.cs

示例2: CanModelBindNonStringData

        public void CanModelBindNonStringData()
        {
            // Arrange
            HttpServer server = new HttpServer();
            MockAssembly assembly = new MockAssembly(typeof(TestController));
            server.Configuration.Services.Replace(typeof(IAssembliesResolver), new TestAssemblyResolver(assembly));

            ODataModelBuilder builder = new ODataConventionModelBuilder();
            builder.EntitySet<TestClass>("Test");
            server.Configuration.Routes.MapODataRoute("odata", "", builder.GetEdmModel());
            HttpClient client = new HttpClient(server);

            // Act
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Test");
            request.GetRoutingConventionsDataStore()["test"] = new TestClass { Id = 42 };
            var response = client.SendAsync(request).Result;

            // Assert
            TestClass result = response.Content.ReadAsAsync<TestClass>().Result;
            Assert.Equal(42, result.Id);
        }
開發者ID:quentez,項目名稱:aspnetwebstack,代碼行數:21,代碼來源:ODataValueProviderFactoryTest.cs

示例3: GetRoutingConventionsDataStore_ReturnsSameInstance_IfCalledMultipleTimes

        public void GetRoutingConventionsDataStore_ReturnsSameInstance_IfCalledMultipleTimes()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();

            // Act
            IDictionary<string, object> instance1 = request.GetRoutingConventionsDataStore();
            IDictionary<string, object> instance2 = request.GetRoutingConventionsDataStore();

            // Assert
            Assert.NotNull(instance1);
            Assert.NotNull(instance2);
            Assert.Same(instance1, instance2);
        }
開發者ID:quentez,項目名稱:aspnetwebstack,代碼行數:14,代碼來源:ODataHttpRequestMessageExtensionsTest.cs

示例4: GetRoutingConventionsDataStore_ReturnsEmptyNonNullDictionary

        public void GetRoutingConventionsDataStore_ReturnsEmptyNonNullDictionary()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();

            // Act
            IDictionary<string, object> result = request.GetRoutingConventionsDataStore();

            // Assert
            Assert.NotNull(result);
            Assert.Empty(result);
        }
開發者ID:quentez,項目名稱:aspnetwebstack,代碼行數:12,代碼來源:ODataHttpRequestMessageExtensionsTest.cs


注:本文中的System.Net.Http.HttpRequestMessage.GetRoutingConventionsDataStore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。