本文整理汇总了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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}