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


C# ObjectContent.LoadIntoBufferAsync方法代码示例

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


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

示例1: ContentHeadersAreAddedForJsonMediaType

        public void ContentHeadersAreAddedForJsonMediaType()
        {
            HttpContent content = new ObjectContent<Person[]>(new Person[] { new Person(0, new ReferenceDepthContext(7)) }, _formatter, "application/json");
            content.LoadIntoBufferAsync().Wait();

            Assert.Http.Contains(content.Headers, "DataServiceVersion", "3.0;");
            Assert.Equal(content.Headers.ContentType.MediaType, "application/json");
        }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:8,代码来源:CollectionTest.cs

示例2: ContentHeadersAreAddedForXmlMediaType

        public void ContentHeadersAreAddedForXmlMediaType()
        {
            ObjectContent<IEnumerable<Person>> content = new ObjectContent<IEnumerable<Person>>(new Person[] { new Person(0, new ReferenceDepthContext(7)) }, _formatter);
            content.LoadIntoBufferAsync().Wait();

            Assert.Http.Contains(content.Headers, "DataServiceVersion", "3.0;");
            Assert.Http.Contains(content.Headers, "Content-Type", "application/xml; charset=utf-8");
        }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:8,代码来源:CollectionTest.cs

示例3: ContentHeadersAreAddedForJsonMediaType

        public void ContentHeadersAreAddedForJsonMediaType()
        {
            ODataMediaTypeFormatter formatter = new ODataMediaTypeFormatter(GetSampleModel()) { Request = GetSampleRequest() };
            HttpContent content = new ObjectContent<Employee>(new Employee(0, new ReferenceDepthContext(7)), formatter, "application/json");
            content.LoadIntoBufferAsync().Wait();

            Assert.Http.Contains(content.Headers, "DataServiceVersion", "3.0;");
            Assert.Http.Contains(content.Headers, "Content-Type", "application/json; odata=verbose; charset=utf-8");
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:9,代码来源:EntityTypeTest.cs

示例4: ContentHeadersAreAddedForXmlMediaType

        public void ContentHeadersAreAddedForXmlMediaType()
        {
            ODataMediaTypeFormatter formatter = new ODataMediaTypeFormatter(GetSampleModel()) { Request = GetSampleRequest() };

            ObjectContent<IEnumerable<Employee>> content = new ObjectContent<IEnumerable<Employee>>(new Employee[] { new Employee(0, new ReferenceDepthContext(7)) }, formatter);
            content.LoadIntoBufferAsync().Wait();

            Assert.Http.Contains(content.Headers, "DataServiceVersion", "3.0;");
            Assert.Http.Contains(content.Headers, "Content-Type", "application/atom+xml; type=feed; charset=utf-8");
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:10,代码来源:FeedTest.cs

示例5: ContentHeadersAreAddedForJsonMediaType

        public void ContentHeadersAreAddedForJsonMediaType()
        {
            ODataMediaTypeFormatter formatter = new ODataMediaTypeFormatter();

            HttpContent content = new ObjectContent<IEnumerable<Employee>>(new Employee[] { new Employee(0, new ReferenceDepthContext(7)) }, formatter, "application/json");
            content.LoadIntoBufferAsync().Wait();

            Assert.Http.Contains(content.Headers, "DataServiceVersion", "3.0;");
            Assert.Equal(content.Headers.ContentType.MediaType, "application/json");
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:10,代码来源:FeedTest.cs

示例6: ContentHeadersAreAddedForXmlMediaType

        public void ContentHeadersAreAddedForXmlMediaType()
        {
            ODataMediaTypeFormatter formatter = new ODataMediaTypeFormatter();

            ObjectContent<Employee> content = new ObjectContent<Employee>(new Employee(0, new ReferenceDepthContext(7)), formatter);
            content.LoadIntoBufferAsync().Wait();

            Assert.Http.Contains(content.Headers, "DataServiceVersion", "3.0;");
            Assert.Http.Contains(content.Headers, "Content-Type", "application/atom+xml; type=entry");
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:10,代码来源:EntityTypeTest.cs


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