本文整理汇总了C#中System.Web.Http.OData.Formatter.Serialization.DefaultODataSerializerProvider类的典型用法代码示例。如果您正苦于以下问题:C# DefaultODataSerializerProvider类的具体用法?C# DefaultODataSerializerProvider怎么用?C# DefaultODataSerializerProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultODataSerializerProvider类属于System.Web.Http.OData.Formatter.Serialization命名空间,在下文中一共展示了DefaultODataSerializerProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor_ThrowsArgumentNull_edmModel
public void Constructor_ThrowsArgumentNull_edmModel()
{
Assert.ThrowsArgumentNull(() =>
{
var serializerProvider = new DefaultODataSerializerProvider(edmModel: null);
}, "edmModel");
}
示例2: GetODataPayloadSerializer_ThrowsArgumentNull_Model
public void GetODataPayloadSerializer_ThrowsArgumentNull_Model()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(model: null, type: null),
"model");
}
示例3: GetODataPayloadSerializer_ThrowsArgumentNull_Type
public void GetODataPayloadSerializer_ThrowsArgumentNull_Type()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(model: EdmCoreModel.Instance, type: null),
"type");
}
示例4: Ctor_SetsProperty_SerializerProvider
public void Ctor_SetsProperty_SerializerProvider()
{
IEdmTypeReference edmType = new Mock<IEdmTypeReference>().Object;
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
var serializer = new Mock<ODataEdmTypeSerializer>(edmType, ODataPayloadKind.Unsupported, serializerProvider).Object;
Assert.Same(serializerProvider, serializer.SerializerProvider);
}
示例5: CreateEdmTypeSerializer_ThrowsArgumentNull_EdmType
public void CreateEdmTypeSerializer_ThrowsArgumentNull_EdmType()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.CreateEdmTypeSerializer(edmType: null),
"edmType");
}
示例6: 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");
}
示例7: 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");
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: 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);
}
示例12: CreateEdmTypeSerializer_Returns_Null_ForUnsupportedType
public void CreateEdmTypeSerializer_Returns_Null_ForUnsupportedType()
{
// Arrange
Mock<IEdmType> unsupportedEdmType = new Mock<IEdmType>();
unsupportedEdmType.Setup(e => e.TypeKind).Returns(EdmTypeKind.None);
Mock<IEdmTypeReference> unsupportedEdmTypeReference = new Mock<IEdmTypeReference>();
unsupportedEdmTypeReference.Setup(e => e.Definition).Returns(unsupportedEdmType.Object);
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
// Act & Assert
Assert.Null(serializerProvider.CreateEdmTypeSerializer(unsupportedEdmTypeReference.Object));
}
示例13: ODataCollectionSerializerTests
public ODataCollectionSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
_edmIntType = EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Int32, isNullable: false);
_customer = new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 10,
};
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
_collectionType = new EdmCollectionTypeReference(new EdmCollectionType(_edmIntType), isNullable: false);
_serializer = new ODataCollectionSerializer(serializerProvider);
}
示例14: ODataEntityTypeSerializerTests
public ODataEntityTypeSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
_customer = new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 10,
};
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider(_model);
_serializer = new ODataEntityTypeSerializer(new EdmEntityTypeReference(_customerSet.ElementType, isNullable: false), serializerProvider);
_urlHelper = new Mock<UrlHelper>(new HttpRequestMessage()).Object;
_writeContext = new ODataSerializerWriteContext(new ODataResponseContext()) { EntitySet = _customerSet, UrlHelper = _urlHelper };
}
示例15: ODataComplexTypeSerializerTests
public ODataComplexTypeSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_address = new Address()
{
Street = "One Microsoft Way",
City = "Redmond",
State = "Washington",
Country = "United States",
ZipCode = "98052"
};
_addressType = _model.FindDeclaredType("Default.Address") as IEdmComplexType;
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
_serializer = new ODataComplexTypeSerializer(new EdmComplexTypeReference(_addressType, isNullable: false), serializerProvider);
}