本文整理汇总了C#中System.Web.Http.OData.Formatter.Serialization.DefaultODataSerializerProvider.GetODataPayloadSerializer方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultODataSerializerProvider.GetODataPayloadSerializer方法的具体用法?C# DefaultODataSerializerProvider.GetODataPayloadSerializer怎么用?C# DefaultODataSerializerProvider.GetODataPayloadSerializer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.OData.Formatter.Serialization.DefaultODataSerializerProvider
的用法示例。
在下文中一共展示了DefaultODataSerializerProvider.GetODataPayloadSerializer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetODataPayloadSerializer_ThrowsArgumentNull_Model
public void GetODataPayloadSerializer_ThrowsArgumentNull_Model()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(model: null, type: null),
"model");
}
示例2: GetODataPayloadSerializer_ThrowsArgumentNull_Type
public void GetODataPayloadSerializer_ThrowsArgumentNull_Type()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(model: EdmCoreModel.Instance, type: null),
"type");
}
示例3: GetODataPayloadSerializer_ThrowsArgumentNull_Model
public void GetODataPayloadSerializer_ThrowsArgumentNull_Model()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(model: null, type: typeof(int), request: request),
"model");
}
示例4: GetODataPayloadSerializer_ThrowsArgumentNull_Request
public void GetODataPayloadSerializer_ThrowsArgumentNull_Request()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(EdmCoreModel.Instance, typeof(int), request: null),
"request");
}
示例5: GetODataSerializer_Primitive
public void GetODataSerializer_Primitive(Type type, EdmPrimitiveTypeKind edmPrimitiveTypeKind)
{
var serializerProvider = new DefaultODataSerializerProvider(_edmModel);
var serializer = serializerProvider.GetODataPayloadSerializer(type);
Assert.NotNull(serializer);
var primitiveSerializer = Assert.IsType<ODataPrimitiveSerializer>(serializer);
Assert.Equal(primitiveSerializer.EdmType.AsPrimitive().PrimitiveKind(), edmPrimitiveTypeKind);
Assert.Equal(primitiveSerializer.ODataPayloadKind, ODataPayloadKind.Property);
}
示例6: GetODataSerializer_Primitive
public void GetODataSerializer_Primitive(Type type, EdmPrimitiveTypeKind edmPrimitiveTypeKind)
{
var serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
var serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, type, request);
Assert.NotNull(serializer);
var primitiveSerializer = Assert.IsType<ODataPrimitiveSerializer>(serializer);
Assert.Equal(primitiveSerializer.ODataPayloadKind, ODataPayloadKind.Property);
}
示例7: GetODataSerializer_Complex
public void GetODataSerializer_Complex()
{
var serializerProvider = new DefaultODataSerializerProvider(_edmModel);
var serializer = serializerProvider.GetODataPayloadSerializer(typeof(ODataEntityDeserializerTests.Address));
Assert.NotNull(serializer);
var complexSerializer = Assert.IsType<ODataComplexTypeSerializer>(serializer);
Assert.True(complexSerializer.EdmType.IsEquivalentTo(_edmModel.GetEdmTypeReference(typeof(ODataEntityDeserializerTests.Address))));
Assert.Equal(complexSerializer.SerializerProvider, serializerProvider);
Assert.Equal(complexSerializer.ODataPayloadKind, ODataPayloadKind.Property);
}
示例8: GetODataSerializer_Entity
public void GetODataSerializer_Entity()
{
var serializerProvider = new DefaultODataSerializerProvider(_edmModel);
var serializer = serializerProvider.GetODataPayloadSerializer(typeof(ODataEntityDeserializerTests.Product));
Assert.NotNull(serializer);
var entitySerializer = Assert.IsType<ODataEntityTypeSerializer>(serializer);
Assert.True(entitySerializer.EdmType.IsEquivalentTo(_edmModel.GetEdmTypeReference(typeof(ODataEntityDeserializerTests.Product))));
Assert.Equal(entitySerializer.SerializerProvider, serializerProvider);
Assert.Equal(entitySerializer.ODataPayloadKind, ODataPayloadKind.Entry);
}
示例9: GetODataSerializer_ReturnsSameSerializer_ForSameType
public void GetODataSerializer_ReturnsSameSerializer_ForSameType()
{
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
ODataSerializer firstCallSerializer = serializerProvider.GetODataPayloadSerializer(_edmModel,
typeof(ODataEntityDeserializerTests.Supplier), request);
ODataSerializer secondCallSerializer = serializerProvider.GetODataPayloadSerializer(_edmModel,
typeof(ODataEntityDeserializerTests.Supplier), request);
Assert.Same(firstCallSerializer, secondCallSerializer);
}
示例10: GetODataSerializer_Returns_ExpectedSerializerType
public void GetODataSerializer_Returns_ExpectedSerializerType(Type payloadType, Type expectedSerializerType)
{
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
ODataSerializer serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, payloadType, request);
Assert.NotNull(serializer);
Assert.IsType(expectedSerializerType, serializer);
}
示例11: GetODataSerializer_ComplexCollection
public void GetODataSerializer_ComplexCollection()
{
var serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
var serializer = serializerProvider.GetODataPayloadSerializer(_edmModel,
typeof(IEnumerable<ODataEntityDeserializerTests.Address>), request);
Assert.NotNull(serializer);
var collectionSerializer = Assert.IsType<ODataCollectionSerializer>(serializer);
Assert.Equal(collectionSerializer.ODataPayloadKind, ODataPayloadKind.Collection);
Assert.Equal(collectionSerializer.SerializerProvider, serializerProvider);
}
示例12: GetODataSerializer_Feed
public void GetODataSerializer_Feed(Type collectionType)
{
var serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
var serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, collectionType, request);
Assert.NotNull(serializer);
var feedSerializer = Assert.IsType<ODataFeedSerializer>(serializer);
Assert.Equal(feedSerializer.ODataPayloadKind, ODataPayloadKind.Feed);
}
示例13: GetODataSerializer_Complex
public void GetODataSerializer_Complex()
{
var serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
var serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, typeof(ODataEntityDeserializerTests.Address), request);
Assert.NotNull(serializer);
var complexSerializer = Assert.IsType<ODataComplexTypeSerializer>(serializer);
Assert.Equal(complexSerializer.SerializerProvider, serializerProvider);
Assert.Equal(complexSerializer.ODataPayloadKind, ODataPayloadKind.Property);
}
示例14: GetODataSerializer_ODataError
public void GetODataSerializer_ODataError()
{
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
ODataSerializer serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, typeof(ODataError));
Assert.NotNull(serializer);
Assert.Equal(typeof(ODataErrorSerializer), serializer.GetType());
Assert.Equal(ODataPayloadKind.Error, serializer.ODataPayloadKind);
}
示例15: GetODataSerializer_ComplexCollection
public void GetODataSerializer_ComplexCollection()
{
var serializerProvider = new DefaultODataSerializerProvider();
var serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, typeof(IEnumerable<ODataEntityDeserializerTests.Address>));
Assert.NotNull(serializer);
var collectionSerializer = Assert.IsType<ODataCollectionSerializer>(serializer);
Assert.True(collectionSerializer.EdmType.IsCollection());
Assert.True(collectionSerializer
.EdmType.AsCollection()
.ElementType()
.IsEquivalentTo(_edmModel.GetEdmTypeReference(typeof(ODataEntityDeserializerTests.Address))));
Assert.Equal(collectionSerializer.ODataPayloadKind, ODataPayloadKind.Collection);
Assert.Equal(collectionSerializer.SerializerProvider, serializerProvider);
}