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


C# DuplicatePropertyNamesChecker.GetODataPropertyAnnotations方法代码示例

本文整理汇总了C#中DuplicatePropertyNamesChecker.GetODataPropertyAnnotations方法的典型用法代码示例。如果您正苦于以下问题:C# DuplicatePropertyNamesChecker.GetODataPropertyAnnotations方法的具体用法?C# DuplicatePropertyNamesChecker.GetODataPropertyAnnotations怎么用?C# DuplicatePropertyNamesChecker.GetODataPropertyAnnotations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DuplicatePropertyNamesChecker的用法示例。


在下文中一共展示了DuplicatePropertyNamesChecker.GetODataPropertyAnnotations方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnlyCustomAnnotationsForPropertyAddedShouldReturnNull

 public void OnlyCustomAnnotationsForPropertyAddedShouldReturnNull()
 {
     DuplicatePropertyNamesChecker duplicateChecker = new DuplicatePropertyNamesChecker(false, true);
     duplicateChecker.AddCustomPropertyAnnotation("property", "custom.annotation");
     duplicateChecker.AddCustomPropertyAnnotation("property", "custom.annotation2");
     duplicateChecker.GetODataPropertyAnnotations("property").Should().BeNull();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:DuplicatePropertyNamesCheckerTests.cs

示例2: 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

示例3: ReadPropertyValueInODataErrorObject

        /// <summary>
        /// Reads a property value which occurs in the "error" object scope.
        /// </summary>
        /// <param name="error">The <see cref="ODataError"/> object to update with the data from this property value.</param>
        /// <param name="propertyName">The name of the property whose value is to be read.</param>
        /// <param name="duplicationPropertyNameChecker">DuplicatePropertyNamesChecker to use for extracting property annotations
        /// targetting any custom instance annotations on the error.</param>
        /// <remarks>
        /// Pre-Condition:  any                         - The value of the property being read.
        /// Post-Condition: JsonNodeType.Property       - The property after the one being read.
        ///                 JsonNodeType.EndObject      - The end of the "error" object.
        ///                 any                         - Anything else after the property value is an invalid payload (but won't fail in this method).
        /// </remarks>
        private void ReadPropertyValueInODataErrorObject(ODataError error, string propertyName, DuplicatePropertyNamesChecker duplicationPropertyNameChecker)
        {
            switch (propertyName)
            {
                case JsonConstants.ODataErrorCodeName:
                    error.ErrorCode = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorCodeName);
                    break;

                case JsonConstants.ODataErrorMessageName:
                    error.Message = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorMessageName);
                    break;

                case JsonConstants.ODataErrorTargetName:
                    error.Target = this.JsonReader.ReadStringValue(JsonConstants.ODataErrorTargetName);
                    break;

                case JsonConstants.ODataErrorDetailsName:
                    error.Details = this.ReadDetails();
                    break;

                case JsonConstants.ODataErrorInnerErrorName:
                    error.InnerError = this.ReadInnerError(0 /* recursionDepth */);
                    break;

                default:
                    // See if it's an instance annotation
                    if (ODataJsonLightReaderUtils.IsAnnotationProperty(propertyName))
                    {
                        ODataJsonLightPropertyAndValueDeserializer valueDeserializer = new ODataJsonLightPropertyAndValueDeserializer(this.JsonLightInputContext);
                        object typeName = null;

                        var odataAnnotations = duplicationPropertyNameChecker.GetODataPropertyAnnotations(propertyName);
                        if (odataAnnotations != null)
                        {
                            odataAnnotations.TryGetValue(ODataAnnotationNames.ODataType, out typeName);
                        }

                        var value = valueDeserializer.ReadNonEntityValue(
                            typeName as string,
                            null /*expectedValueTypeReference*/,
                            null /*duplicatePropertiesNamesChecker*/,
                            null /*collectionValidator*/, 
                            false /*validateNullValue*/, 
                            false /*isTopLevelPropertyValue*/,
                            false /*insideComplexValue*/,
                            propertyName);

                        error.GetInstanceAnnotations().Add(new ODataInstanceAnnotation(propertyName, value.ToODataValue()));
                    }
                    else
                    {
                        // we only allow a 'code', 'message', 'target', 'details, and 'innererror' properties
                        // in the value of the 'error' property or custom instance annotations
                        throw new ODataException(Strings.ODataJsonLightErrorDeserializer_TopLevelErrorValueWithInvalidProperty(propertyName));
                    }

                    break;
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:72,代码来源:ODataJsonLightErrorDeserializer.cs

示例4: ValidateDataPropertyTypeNameAnnotation

        /// <summary>
        /// Gets and validates the type name annotation for the specified property.
        /// </summary>
        /// <param name="duplicatePropertyNamesChecker">The duplicate property names checker in use for the entry content.</param>
        /// <param name="propertyName">The name of the property to get the type name for.</param>
        /// <returns>The type name for the property or null if no type name was found.</returns>
        protected static string ValidateDataPropertyTypeNameAnnotation(DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, string propertyName)
        {
            Debug.Assert(duplicatePropertyNamesChecker != null, "duplicatePropertyNamesChecker != null");
            Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");

            Dictionary<string, object> propertyAnnotations = duplicatePropertyNamesChecker.GetODataPropertyAnnotations(propertyName);
            string propertyTypeName = null;
            if (propertyAnnotations != null)
            {
                foreach (KeyValuePair<string, object> propertyAnnotation in propertyAnnotations)
                {
                    if (string.CompareOrdinal(propertyAnnotation.Key, ODataAnnotationNames.ODataType) != 0)
                    {
                        throw new ODataException(ODataErrorStrings.ODataJsonLightPropertyAndValueDeserializer_UnexpectedDataPropertyAnnotation(propertyName, propertyAnnotation.Key));
                    }

                    Debug.Assert(propertyAnnotation.Value is string && propertyAnnotation.Value != null, "The odata.type annotation should have been parsed as a non-null string.");
                    propertyTypeName = (string)propertyAnnotation.Value;
                }
            }

            return propertyTypeName;
        }
开发者ID:modulexcite,项目名称:odata.net,代码行数:29,代码来源:ODataJsonLightPropertyAndValueDeserializer.cs

示例5: ReadCustomInstanceAnnotationValue

        /// <summary>
        /// Reads the value of the instance annotation.
        /// </summary>
        /// <param name="duplicatePropertyNamesChecker">The duplicate property names checker instance.</param>
        /// <param name="name">The name of the instance annotation.</param>
        /// <returns>Returns the value of the instance annotation.</returns>
        internal object ReadCustomInstanceAnnotationValue(DuplicatePropertyNamesChecker duplicatePropertyNamesChecker, string name)
        {
            Debug.Assert(duplicatePropertyNamesChecker != null, "duplicatePropertyNamesChecker != null");
            Debug.Assert(!string.IsNullOrEmpty(name), "!string.IsNullOrEmpty(name)");

            var propertyAnnotations = duplicatePropertyNamesChecker.GetODataPropertyAnnotations(name);
            object propertyAnnotation;
            string odataType = null;
            if (propertyAnnotations != null && propertyAnnotations.TryGetValue(ODataAnnotationNames.ODataType, out propertyAnnotation))
            {
                odataType = ReaderUtils.AddEdmPrefixOfTypeName(ReaderUtils.RemovePrefixOfTypeName((string)propertyAnnotation));
            }

            // If this term is defined in the model, look up its type. If the term is not in the model, this will be null.
            IEdmTypeReference expectedTypeFromTerm = MetadataUtils.LookupTypeOfValueTerm(name, this.Model);

            object customInstanceAnnotationValue = this.ReadNonEntityValueImplementation(
                odataType,
                expectedTypeFromTerm,
                null, /*duplicatePropertyNamesChecker*/
                null, /*collectionValidator*/
                false, /*validateNullValue*/
                false, /*isTopLevelPropertyValue*/
                false, /*insideComplexValue Always pass false here to try read @odata.type annotation in custom instance annotations*/
                name);
            return customInstanceAnnotationValue;
        }
开发者ID:modulexcite,项目名称:odata.net,代码行数:33,代码来源:ODataJsonLightPropertyAndValueDeserializer.cs

示例6: NoAnnotationsForPropertyAddedShouldReturnNull

 public void NoAnnotationsForPropertyAddedShouldReturnNull()
 {
     DuplicatePropertyNamesChecker duplicateChecker = new DuplicatePropertyNamesChecker(false, true);
     duplicateChecker.GetODataPropertyAnnotations("property").Should().BeNull();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:5,代码来源:DuplicatePropertyNamesCheckerTests.cs

示例7: NoAnnotationsForObjectScopeAddedShouldReturnNull

 public void NoAnnotationsForObjectScopeAddedShouldReturnNull()
 {
     DuplicatePropertyNamesChecker duplicateChecker = new DuplicatePropertyNamesChecker(false, true);
     duplicateChecker.GetODataPropertyAnnotations(string.Empty).Should().BeNull();
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:5,代码来源:DuplicatePropertyNamesCheckerTests.cs


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