当前位置: 首页>>代码示例>>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;未经允许,请勿转载。