本文整理汇总了C#中System.Web.Http.OData.Formatter.Serialization.DefaultODataSerializerProvider类的典型用法代码示例。如果您正苦于以下问题:C# DefaultODataSerializerProvider类的具体用法?C# DefaultODataSerializerProvider怎么用?C# DefaultODataSerializerProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultODataSerializerProvider类属于System.Web.Http.OData.Formatter.Serialization命名空间,在下文中一共展示了DefaultODataSerializerProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Constructor_ThrowsArgumentNull_edmModel
public void Constructor_ThrowsArgumentNull_edmModel()
{
Assert.ThrowsArgumentNull(() =>
{
var serializerProvider = new DefaultODataSerializerProvider(edmModel: null);
}, "edmModel");
}
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:7,代码来源:DefaultODataSerializerProviderTests.cs
示例2: GetODataPayloadSerializer_ThrowsArgumentNull_Model
public void GetODataPayloadSerializer_ThrowsArgumentNull_Model()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(model: null, type: null),
"model");
}
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:8,代码来源:DefaultODataSerializerProviderTests.cs
示例3: GetODataPayloadSerializer_ThrowsArgumentNull_Type
public void GetODataPayloadSerializer_ThrowsArgumentNull_Type()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.GetODataPayloadSerializer(model: EdmCoreModel.Instance, type: null),
"type");
}
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:8,代码来源:DefaultODataSerializerProviderTests.cs
示例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);
}
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:8,代码来源:ODataEdmTypeSerializerTest.cs
示例5: CreateEdmTypeSerializer_ThrowsArgumentNull_EdmType
public void CreateEdmTypeSerializer_ThrowsArgumentNull_EdmType()
{
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
Assert.ThrowsArgumentNull(
() => serializerProvider.CreateEdmTypeSerializer(edmType: null),
"edmType");
}
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:8,代码来源:DefaultODataSerializerProviderTests.cs
示例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");
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:9,代码来源:DefaultODataSerializerProviderTests.cs
示例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");
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:9,代码来源:DefaultODataSerializerProviderTests.cs
示例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);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:10,代码来源:DefaultODataSerializerProviderTests.cs
示例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);
}
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:10,代码来源:DefaultODataSerializerProviderTests.cs
示例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);
}
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:11,代码来源:DefaultODataSerializerProviderTests.cs
示例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);
}
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:11,代码来源:DefaultODataSerializerProviderTests.cs
示例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));
}
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:12,代码来源:DefaultODataSerializerProviderTests.cs
示例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);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:16,代码来源:ODataCollectionSerializerTests.cs
示例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 };
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:16,代码来源:ODataEntityTypeSerializerTests.cs
示例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);
}
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:17,代码来源:ODataComplexTypeSerializerTests.cs
示例16: ODataEntityTypeSerializerTests
public ODataEntityTypeSerializerTests()
{
_model = SerializationTestsHelpers.SimpleCustomerOrderModel();
_model.SetAnnotationValue<ClrTypeAnnotation>(_model.FindType("Default.Customer"), new ClrTypeAnnotation(typeof(Customer)));
_model.SetAnnotationValue<ClrTypeAnnotation>(_model.FindType("Default.Order"), new ClrTypeAnnotation(typeof(Order)));
_customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
_customer = new Customer()
{
FirstName = "Foo",
LastName = "Bar",
ID = 10,
};
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
_serializer = new ODataEntityTypeSerializer(
new EdmEntityTypeReference(_customerSet.ElementType, isNullable: false),
serializerProvider);
_writeContext = new ODataSerializerContext() { EntitySet = _customerSet, Model = _model };
}
开发者ID:sujiantao,项目名称:aspnetwebstack,代码行数:21,代码来源:ODataEntityTypeSerializerTests.cs
示例17: GetODataPayloadSerializer_ReturnsRawValueSerializer_ForValueRequests
public void GetODataPayloadSerializer_ReturnsRawValueSerializer_ForValueRequests(Type type, EdmPrimitiveTypeKind edmPrimitiveTypeKind)
{
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
HttpRequestMessage request = new HttpRequestMessage();
request.ODataProperties().Path = new ODataPath(new ValuePathSegment());
var serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, type, request);
Assert.NotNull(serializer);
Assert.Equal(ODataPayloadKind.Value, serializer.ODataPayloadKind);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:11,代码来源:DefaultODataSerializerProviderTests.cs
示例18: GetODataSerializer_Feed
public void GetODataSerializer_Feed(Type collectionType)
{
var serializerProvider = new DefaultODataSerializerProvider();
var serializer = serializerProvider.GetODataPayloadSerializer(_edmModel, collectionType);
Assert.NotNull(serializer);
var feedSerializer = Assert.IsType<ODataFeedSerializer>(serializer);
Assert.True(feedSerializer.EdmType.IsCollection());
Assert.True(feedSerializer.EdmType.AsCollection().ElementType().IsEquivalentTo(_edmModel.GetEdmTypeReference(typeof(ODataEntityDeserializerTests.Supplier))));
}
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:10,代码来源:DefaultODataSerializerProviderTests.cs
示例19: WriteObjectInline_Calls_CreateNavigationLinks
public void WriteObjectInline_Calls_CreateNavigationLinks()
{
// Arrange
var entityInstance = new object();
ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
ODataWriter writer = new Mock<ODataWriter>().Object;
Mock<ODataEntityTypeSerializer> serializer = new Mock<ODataEntityTypeSerializer>(_serializer.EdmType, serializerProvider);
serializer.CallBase = true;
_writeContext.Request = new HttpRequestMessage();
_writeContext.Url = new UrlHelper(_writeContext.Request);
serializer.Setup(s => s.CreateEntry(It.IsAny<EntityInstanceContext>(), _writeContext)).Returns(new ODataEntry());
serializer
.Setup(s => s.CreateNavigationLinks(It.IsAny<EntityInstanceContext>(), _writeContext))
.Callback((EntityInstanceContext instanceContext, ODataSerializerContext writeContext) =>
{
VerifyEntityInstanceContext(instanceContext, writeContext);
Assert.Equal(entityInstance, instanceContext.EntityInstance);
Assert.Equal(serializer.Object.EdmType.Definition, instanceContext.EntityType);
});
// Act
serializer.Object.WriteObjectInline(entityInstance, writer, _writeContext);
// Assert
serializer.VerifyAll();
}
开发者ID:balajivasudevan,项目名称:aspnetwebstack,代码行数:26,代码来源:ODataEntityTypeSerializerTests.cs
示例20: GetEdmTypeSerializer_Caches_CreateEdmTypeSerializerOutput
public void GetEdmTypeSerializer_Caches_CreateEdmTypeSerializerOutput()
{
// Arrange
DefaultODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();
IEdmTypeReference edmType = new Mock<IEdmTypeReference>().Object;
// Act
var serializer1 = serializerProvider.GetEdmTypeSerializer(edmType);
var serializer2 = serializerProvider.GetEdmTypeSerializer(edmType);
// Assert
Assert.Same(serializer2, serializer1);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:13,代码来源:DefaultODataSerializerProviderTests.cs
注:本文中的System.Web.Http.OData.Formatter.Serialization.DefaultODataSerializerProvider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论