本文整理汇总了C#中DuplicatePropertyNamesChecker.GetCustomPropertyAnnotations方法的典型用法代码示例。如果您正苦于以下问题:C# DuplicatePropertyNamesChecker.GetCustomPropertyAnnotations方法的具体用法?C# DuplicatePropertyNamesChecker.GetCustomPropertyAnnotations怎么用?C# DuplicatePropertyNamesChecker.GetCustomPropertyAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DuplicatePropertyNamesChecker
的用法示例。
在下文中一共展示了DuplicatePropertyNamesChecker.GetCustomPropertyAnnotations方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadComplexValue
//.........这里部分代码省略.........
if (string.CompareOrdinal(ODataAnnotationNames.ODataType, propertyName) == 0)
{
throw new ODataException(ODataErrorStrings.ODataJsonLightPropertyAndValueDeserializer_ComplexTypeAnnotationNotFirst);
}
else
{
throw new ODataException(ODataErrorStrings.ODataJsonLightPropertyAndValueDeserializer_UnexpectedAnnotationProperties(propertyName));
}
case PropertyParsingResult.CustomInstanceAnnotation:
ODataAnnotationNames.ValidateIsCustomAnnotationName(propertyName);
Debug.Assert(
!this.MessageReaderSettings.ShouldSkipAnnotation(propertyName),
"!this.MessageReaderSettings.ShouldReadAndValidateAnnotation(annotationName) -- otherwise we should have already skipped the custom annotation and won't see it here.");
var customInstanceAnnotationValue = this.ReadCustomInstanceAnnotationValue(duplicatePropertyNamesChecker, propertyName);
complexValue.InstanceAnnotations.Add(new ODataInstanceAnnotation(propertyName, customInstanceAnnotationValue.ToODataValue()));
break;
case PropertyParsingResult.PropertyWithoutValue:
throw new ODataException(ODataErrorStrings.ODataJsonLightPropertyAndValueDeserializer_ComplexValuePropertyAnnotationWithoutProperty(propertyName));
case PropertyParsingResult.PropertyWithValue:
// Any other property is data
ODataProperty property = new ODataProperty();
property.Name = propertyName;
// Lookup the property in metadata
IEdmProperty edmProperty = null;
bool ignoreProperty = false;
if (complexValueTypeReference != null)
{
edmProperty = ReaderValidationUtils.ValidateValuePropertyDefined(propertyName, complexValueTypeReference.ComplexDefinition(), this.MessageReaderSettings, out ignoreProperty);
}
if (ignoreProperty
&& (this.JsonReader.NodeType == JsonNodeType.StartObject || this.JsonReader.NodeType == JsonNodeType.StartArray))
{
this.JsonReader.SkipValue();
}
else
{
// EdmLib bridge marks all key properties as non-nullable, but Astoria allows them to be nullable.
// If the property has an annotation to ignore null values, we need to omit the property in requests.
ODataNullValueBehaviorKind nullValueReadBehaviorKind = this.ReadingResponse || edmProperty == null
? ODataNullValueBehaviorKind.Default
: this.Model.NullValueReadBehaviorKind(edmProperty);
// Read the property value
object propertyValue = this.ReadNonEntityValueImplementation(
ValidateDataPropertyTypeNameAnnotation(duplicatePropertyNamesChecker, propertyName),
edmProperty == null ? null : edmProperty.Type,
/*duplicatePropertyNamesChecker*/ null,
/*collectionValidator*/ null,
nullValueReadBehaviorKind == ODataNullValueBehaviorKind.Default,
/*isTopLevelPropertyValue*/ false,
/*insideComplexValue*/ false,
propertyName,
edmProperty == null);
if (nullValueReadBehaviorKind != ODataNullValueBehaviorKind.IgnoreValue || propertyValue != null)
{
duplicatePropertyNamesChecker.CheckForDuplicatePropertyNames(property);
property.Value = propertyValue;
var propertyAnnotations = duplicatePropertyNamesChecker.GetCustomPropertyAnnotations(propertyName);
if (propertyAnnotations != null)
{
foreach (var annotation in propertyAnnotations)
{
if (annotation.Value != null)
{
// annotation.Value == null indicates that this annotation should be skipped.
property.InstanceAnnotations.Add(new ODataInstanceAnnotation(annotation.Key, annotation.Value.ToODataValue()));
}
}
}
properties.Add(property);
}
}
break;
case PropertyParsingResult.EndOfObject:
break;
case PropertyParsingResult.MetadataReferenceProperty:
throw new ODataException(ODataErrorStrings.ODataJsonLightPropertyAndValueDeserializer_UnexpectedMetadataReferenceProperty(propertyName));
}
});
}
Debug.Assert(this.JsonReader.NodeType == JsonNodeType.EndObject, "After all the properties of a complex value are read the EndObject node is expected.");
this.JsonReader.ReadEndObject();
complexValue.Properties = new ReadOnlyEnumerable<ODataProperty>(properties);
this.DecreaseRecursionDepth();
return complexValue;
}