当前位置: 首页>>代码示例>>C#>>正文


C# DuplicatePropertyNamesChecker.AddODataPropertyAnnotation方法代码示例

本文整理汇总了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" }
     });
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:11,代码来源:DuplicatePropertyNamesCheckerTests.cs

示例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"));
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:DuplicatePropertyNamesCheckerTests.cs

示例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();
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:8,代码来源:ODataJsonLightEntryAndFeedDeserializerTests.cs

示例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"));
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:9,代码来源:DuplicatePropertyNamesCheckerTests.cs

示例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 } });
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:9,代码来源:ODataJsonLightEntryAndFeedDeserializerTests.cs

示例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);
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:11,代码来源:ODataJsonLightEntryAndFeedDeserializerTests.cs

示例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"));
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:9,代码来源:ODataJsonLightEntryAndFeedDeserializerTests.cs

示例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"));
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:11,代码来源:ODataJsonLightEntryAndFeedDeserializerTests.cs

示例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);
 }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:8,代码来源:ODataJsonLightEntryAndFeedDeserializerTests.cs


注:本文中的DuplicatePropertyNamesChecker.AddODataPropertyAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。