本文整理汇总了C#中DuplicatePropertyNamesChecker.AddODataPropertyAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# DuplicatePropertyNamesChecker.AddODataPropertyAnnotation方法的具体用法?C# DuplicatePropertyNamesChecker.AddODataPropertyAnnotation怎么用?C# DuplicatePropertyNamesChecker.AddODataPropertyAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DuplicatePropertyNamesChecker
的用法示例。
在下文中一共展示了DuplicatePropertyNamesChecker.AddODataPropertyAnnotation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnnotationsForPropertyShouldBeStored
public void AnnotationsForPropertyShouldBeStored()
{
DuplicatePropertyNamesChecker duplicateChecker = new DuplicatePropertyNamesChecker(false, true);
duplicateChecker.AddODataPropertyAnnotation("property", JsonLightConstants.ODataAnnotationNamespacePrefix + "one", 1);
duplicateChecker.AddODataPropertyAnnotation("property", JsonLightConstants.ODataAnnotationNamespacePrefix + "two", "Two");
duplicateChecker.GetODataPropertyAnnotations("property").Should().Equal(new Dictionary<string, object>()
{
{ JsonLightConstants.ODataAnnotationNamespacePrefix + "one", 1 },
{ JsonLightConstants.ODataAnnotationNamespacePrefix + "two", "Two" }
});
}
示例2: DuplicatePropertyODataAnnotationShouldFail
public void DuplicatePropertyODataAnnotationShouldFail()
{
DuplicatePropertyNamesChecker duplicateChecker = new DuplicatePropertyNamesChecker(false, true);
Action action = () => duplicateChecker.AddODataPropertyAnnotation("property", JsonLightConstants.ODataAnnotationNamespacePrefix + "name", null);
action.ShouldNotThrow();
action.ShouldThrow<ODataException>().WithMessage(ErrorStrings.DuplicatePropertyNamesChecker_DuplicateAnnotationForPropertyNotAllowed(JsonLightConstants.ODataAnnotationNamespacePrefix + "name", "property"));
}
示例3: ReadInstanceAnnotationValueWillReadNullValueWithODataType
public void ReadInstanceAnnotationValueWillReadNullValueWithODataType()
{
var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odata.NullAnnotation\":null}");
AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
var duplicatePropertyNamesChecker = new DuplicatePropertyNamesChecker(false /*allowDuplicateProperties*/, true /*isResponse*/);
duplicatePropertyNamesChecker.AddODataPropertyAnnotation("odata.NullAnnotation", "odata.type", "Edm.Guid");
deserializer.ReadCustomInstanceAnnotationValue(duplicatePropertyNamesChecker, "odata.NullAnnotation").Should().BeNull();
}
示例4: MarkPropertyAsProcessedWithNoPropertyShouldWork
public void MarkPropertyAsProcessedWithNoPropertyShouldWork()
{
DuplicatePropertyNamesChecker duplicateChecker = new DuplicatePropertyNamesChecker(false, true);
duplicateChecker.MarkPropertyAsProcessed("property");
Action odataAction = () => duplicateChecker.AddODataPropertyAnnotation("property", JsonLightConstants.ODataAnnotationNamespacePrefix + "name", null);
odataAction.ShouldThrow<ODataException>().WithMessage(ErrorStrings.DuplicatePropertyNamesChecker_PropertyAnnotationAfterTheProperty(JsonLightConstants.ODataAnnotationNamespacePrefix + "name", "property"));
Action customAction = () => duplicateChecker.AddCustomPropertyAnnotation("property", "custom.name");
customAction.ShouldThrow<ODataException>().WithMessage(ErrorStrings.DuplicatePropertyNamesChecker_PropertyAnnotationAfterTheProperty("custom.name", "property"));
}
示例5: ReadInstanceAnnotationValueShouldReadCollectionOfPrimitiveValues
public void ReadInstanceAnnotationValueShouldReadCollectionOfPrimitiveValues()
{
var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@custom.primitiveCollectionAnnotation\":[1,2,3]}");
AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
var duplicatePropertyNamesChecker = new DuplicatePropertyNamesChecker(false /*allowDuplicateProperties*/, true /*isResponse*/);
duplicatePropertyNamesChecker.AddODataPropertyAnnotation("custom.primitiveCollectionAnnotation", "odata.type", "Collection(Edm.Int32)");
ODataCollectionValue value = (ODataCollectionValue)deserializer.ReadCustomInstanceAnnotationValue(duplicatePropertyNamesChecker, "custom.primitiveCollectionAnnotation");
TestUtils.AssertODataValueAreEqual(value, new ODataCollectionValue { TypeName = "Collection(Edm.Int32)", Items = new[] { 1, 2, 3 } });
}
示例6: ReadInstanceAnnotationValueShouldReadCollectionOfComplexValues
public void ReadInstanceAnnotationValueShouldReadCollectionOfComplexValues()
{
var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@custom.complexCollectionAnnotation\":[{\"StringProperty\":\"StringValue\"}]}");
AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
var duplicatePropertyNamesChecker = new DuplicatePropertyNamesChecker(false /*allowDuplicateProperties*/, true /*isResponse*/);
duplicatePropertyNamesChecker.AddODataPropertyAnnotation("custom.complexCollectionAnnotation", "odata.type", "Collection(TestNamespace.TestComplexType)");
ODataCollectionValue value = (ODataCollectionValue)deserializer.ReadCustomInstanceAnnotationValue(duplicatePropertyNamesChecker, "custom.complexCollectionAnnotation");
var odataComplexValue = new ODataComplexValue { TypeName = "TestNamespace.TestComplexType", Properties = new[] { new ODataProperty { Name = "StringProperty", Value = "StringValue" } } };
var odataCollectionValue = new ODataCollectionValue { TypeName = "Collection(TestNamespace.TestComplexType)", Items = new[] { odataComplexValue } };
TestUtils.AssertODataValueAreEqual(value, odataCollectionValue);
}
示例7: ReadInstanceAnnotationValueWithODataTypePropertyAnnotationShouldThrow
public void ReadInstanceAnnotationValueWithODataTypePropertyAnnotationShouldThrow()
{
var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@odata.ComplexAnnotation\":{\"StringProperty\":\"StringValue\"}}");
AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
var duplicatePropertyNamesChecker = new DuplicatePropertyNamesChecker(false /*allowDuplicateProperties*/, true /*isResponse*/);
duplicatePropertyNamesChecker.AddODataPropertyAnnotation("odata.ComplexAnnotation", "odata.type", "TestNamespace.TestComplexType");
Action action = () => deserializer.ReadCustomInstanceAnnotationValue(duplicatePropertyNamesChecker, "odata.ComplexAnnotation");
action.ShouldThrow<ODataException>().WithMessage(ErrorStrings.ODataJsonLightPropertyAndValueDeserializer_ComplexValueWithPropertyTypeAnnotation("odata.type"));
}
示例8: ReadInstanceAnnotationValueShouldThrowIfWireTypeAndModelTypeConflict
public void ReadInstanceAnnotationValueShouldThrowIfWireTypeAndModelTypeConflict()
{
var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@custom.DateTimeOffsetAnnotation\":\"2013-01-25T09:50Z\"}");
AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
var duplicatePropertyNamesChecker = new DuplicatePropertyNamesChecker(false /*allowDuplicateProperties*/, true /*isResponse*/);
duplicatePropertyNamesChecker.AddODataPropertyAnnotation("custom.DateTimeOffsetAnnotation", "odata.type", "Edm.String");
Action testSubject = () => deserializer.ReadCustomInstanceAnnotationValue(duplicatePropertyNamesChecker, "custom.DateTimeOffsetAnnotation");
testSubject.ShouldThrow<ODataException>().WithMessage(ErrorStrings.ValidationUtils_IncompatibleType("Edm.String", "Edm.DateTimeOffset"));
}
示例9: ReadInstanceAnnotationValueWillReadAsCorrectTypePrimitiveTypesWithODataTypeAnnotation
public void ReadInstanceAnnotationValueWillReadAsCorrectTypePrimitiveTypesWithODataTypeAnnotation()
{
var deserializer = this.CreateJsonLightEntryAndFeedDeserializer("{\"@Custom.GuidAnnotation\":\"00000000-0000-0000-0000-000000000000\"}");
AdvanceReaderToFirstPropertyValue(deserializer.JsonReader);
var duplicatePropertyNamesChecker = new DuplicatePropertyNamesChecker(false /*allowDuplicateProperties*/, true /*isResponse*/);
duplicatePropertyNamesChecker.AddODataPropertyAnnotation("Custom.GuidAnnotation", "odata.type", "Edm.Guid");
deserializer.ReadCustomInstanceAnnotationValue(duplicatePropertyNamesChecker, "Custom.GuidAnnotation").Should().Be(Guid.Empty);
}