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


C# HttpRequestMessage.SetFakeODataRouteName方法代碼示例

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


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

示例1: GetSampleRequest

 private static HttpRequestMessage GetSampleRequest()
 {
     HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/property");
     request.SetEdmModel(GetSampleModel());
     HttpConfiguration configuration = new HttpConfiguration();
     configuration.Routes.MapFakeODataRoute();
     request.SetConfiguration(configuration);
     request.SetFakeODataRouteName();
     return request;
 }
開發者ID:naulizzang,項目名稱:aspnetwebstack,代碼行數:10,代碼來源:ComplexTypeTest.cs

示例2: PrimitiveTypesSerializeAsOData

        public void PrimitiveTypesSerializeAsOData(Type valueType, object value, MediaTypeHeaderValue mediaType,
            string resourceName)
        {
            string expectedEntity = Resources.GetString(resourceName);
            Assert.NotNull(expectedEntity);

            ODataConventionModelBuilder modelBuilder = new ODataConventionModelBuilder();
            modelBuilder.EntitySet<WorkItem>("WorkItems");
            IEdmModel model = modelBuilder.GetEdmModel();

            string actualEntity;

            using (HttpConfiguration configuration = CreateConfiguration())
            using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get,
                "http://localhost/WorkItems(10)/ID"))
            {
                request.SetConfiguration(configuration);
                IEdmProperty property =
                    model.EntityContainer.EntitySets().Single().EntityType().Properties().First();
                request.ODataProperties().Model = model;
                request.ODataProperties().Path = new ODataPath(new PropertyAccessPathSegment(property));
                request.SetFakeODataRouteName();

                ODataMediaTypeFormatter formatter = CreateFormatter(request);
                formatter.SupportedMediaTypes.Add(mediaType);

                Type type = (value != null) ? value.GetType() : typeof(Nullable<int>);

                using (ObjectContent content = new ObjectContent(type, value, formatter))
                {
                    actualEntity = content.ReadAsStringAsync().Result;
                }
            }

            bool isJson = resourceName.EndsWith(".json");

            if (isJson)
            {
                JsonAssert.Equal(expectedEntity, actualEntity);
            }
            else
            {
                Assert.Xml.Equal(expectedEntity, actualEntity);
            }
        }
開發者ID:KevMoore,項目名稱:aspnetwebstack,代碼行數:45,代碼來源:PrimitiveTypesTest.cs

示例3: CreateMetadataLinkFactory

 private static UrlHelper CreateMetadataLinkFactory(string metadataPath)
 {
     HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, metadataPath);
     HttpConfiguration configuration = new HttpConfiguration();
     configuration.Routes.MapFakeODataRoute();
     request.SetConfiguration(configuration);
     request.SetFakeODataRouteName();
     return new UrlHelper(request);
 }
開發者ID:KevMoore,項目名稱:aspnetwebstack,代碼行數:9,代碼來源:ODataEntityTypeSerializerTests.cs

示例4: AddRequestInfo

 private void AddRequestInfo(HttpRequestMessage request)
 {
     request.ODataProperties().Path = new DefaultODataPathHandler()
         .Parse(_model, GetODataPath(request.RequestUri.AbsoluteUri));
     request.ODataProperties().Model = _model;
     request.SetFakeODataRouteName();
 }
開發者ID:KevMoore,項目名稱:aspnetwebstack,代碼行數:7,代碼來源:InheritanceTests.cs

示例5: AddRequestInfo

 private void AddRequestInfo(HttpRequestMessage request)
 {
     request.SetODataPath(new DefaultODataPathHandler().Parse(_model, GetODataPath(
         request.RequestUri.AbsoluteUri)));
     request.SetEdmModel(_model);
     request.SetFakeODataRouteName();
 }
開發者ID:sujiantao,項目名稱:aspnetwebstack,代碼行數:7,代碼來源:InheritanceTests.cs


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