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


C# IEdmStructuredType.FindProperty方法代码示例

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


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

示例1: ValidatePropertyDefined

        /// <summary>
        /// Validates that a property with the specified name exists on a given structured type.
        /// The structured type can be null if no metadata is available.
        /// </summary>
        /// <param name="propertyName">The name of the property to validate.</param>
        /// <param name="owningStructuredType">The owning type of the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</param>
        /// <param name="throwOnMissingProperty">Whether throw exception on missing property.</param>
        /// <returns>The <see cref="IEdmProperty"/> instance representing the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</returns>
        public IEdmProperty ValidatePropertyDefined(
            string propertyName,
            IEdmStructuredType owningStructuredType,
            bool throwOnMissingProperty = true)
        {
            if (owningStructuredType == null)
            {
                return null;
            }

            return owningStructuredType.FindProperty(propertyName);
        }
开发者ID:TomDu,项目名称:odata.net,代码行数:22,代码来源:WriterValidatorMinimalValidation.cs

示例2: FindDefinedProperty

 internal static IEdmProperty FindDefinedProperty(string propertyName, IEdmStructuredType owningStructuredType, ODataMessageReaderSettings messageReaderSettings)
 {
     if (owningStructuredType == null)
     {
         return null;
     }
     IEdmProperty property = owningStructuredType.FindProperty(propertyName);
     if (((property == null) && owningStructuredType.IsOpen) && (messageReaderSettings.UndeclaredPropertyBehaviorKinds != ODataUndeclaredPropertyBehaviorKinds.None))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ReaderValidationUtils_UndeclaredPropertyBehaviorKindSpecifiedForOpenType(propertyName, owningStructuredType.ODataFullName()));
     }
     return property;
 }
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:ReaderValidationUtils.cs

示例3: ValidatePropertyDefined

        /// <summary>
        /// Validates that a property with the specified name exists on a given structured type.
        /// The structured type can be null if no metadata is available.
        /// </summary>
        /// <param name="propertyName">The name of the property to validate.</param>
        /// <param name="owningStructuredType">The owning type of the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</param>
        /// <param name="throwOnMissingProperty">Whether throw exception on missing property.</param>
        /// <returns>The <see cref="IEdmProperty"/> instance representing the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</returns>
        internal static IEdmProperty ValidatePropertyDefined(
            string propertyName,
            IEdmStructuredType owningStructuredType,
            bool throwOnMissingProperty = true)
        {
            Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");

            if (owningStructuredType == null)
            {
                return null;
            }

            IEdmProperty property = owningStructuredType.FindProperty(propertyName);

            // verify that the property is declared if the type is not an open type.
            if (throwOnMissingProperty && !owningStructuredType.IsOpen && property == null)
            {
                throw new ODataException(Strings.ValidationUtils_PropertyDoesNotExistOnType(propertyName, owningStructuredType.ODataFullName()));
            }

            return property;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:32,代码来源:WriterValidationUtils.cs

示例4: ResolveProperty

        /// <summary>
        /// Resolve property from property name
        /// </summary>
        /// <param name="type">The declaring type.</param>
        /// <param name="propertyName">The property name.</param>
        /// <returns>The resolved <see cref="IEdmProperty"/></returns>
        public virtual IEdmProperty ResolveProperty(IEdmStructuredType type, string propertyName)
        {
            if (EnableCaseInsensitive)
            {
                var result = type.Properties()
                .Where(_ => string.Equals(propertyName, _.Name, StringComparison.OrdinalIgnoreCase))
                .ToList();

                if (result.Count == 1)
                {
                    return result.Single();
                }
                else if (result.Count > 1)
                {
                    throw new ODataException(Strings.UriParserMetadata_MultipleMatchingPropertiesFound(propertyName, type.FullTypeName()));
                }
            }

            return type.FindProperty(propertyName);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:26,代码来源:ODataUriResolver.cs

示例5: FindDefinedProperty

        /// <summary>
        /// Finds a defined property from the model if one is available.
        /// The structured type can be null if no metadata is available.
        /// </summary>
        /// <param name="propertyName">The name of the property to find.</param>
        /// <param name="owningStructuredType">The owning type of the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</param>
        /// <returns>The <see cref="IEdmProperty"/> instance representing the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</returns>
        internal static IEdmProperty FindDefinedProperty(string propertyName, IEdmStructuredType owningStructuredType)
        {
            Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");

            if (owningStructuredType == null)
            {
                return null;
            }

            IEdmProperty property = owningStructuredType.FindProperty(propertyName);
            return property;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:21,代码来源:ReaderValidationUtils.cs

示例6: ValidatePropertyDefined

 internal static IEdmProperty ValidatePropertyDefined(string propertyName, IEdmStructuredType owningStructuredType)
 {
     if (owningStructuredType == null)
     {
         return null;
     }
     IEdmProperty property = owningStructuredType.FindProperty(propertyName);
     if (!owningStructuredType.IsOpen && (property == null))
     {
         throw new ODataException(Microsoft.Data.OData.Strings.ValidationUtils_PropertyDoesNotExistOnType(propertyName, owningStructuredType.ODataFullName()));
     }
     return property;
 }
开发者ID:nickchal,项目名称:pash,代码行数:13,代码来源:WriterValidationUtils.cs

示例7: FindDefinedProperty

        /// <summary>
        /// Finds a defined property from the model if one is available.
        /// The structured type can be null if no metadata is available.
        /// </summary>
        /// <param name="propertyName">The name of the property to find.</param>
        /// <param name="owningStructuredType">The owning type of the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</param>
        /// <param name="messageReaderSettings">The message reader settings being used.</param>
        /// <returns>The <see cref="IEdmProperty"/> instance representing the property with name <paramref name="propertyName"/> 
        /// or null if no metadata is available.</returns>
        internal static IEdmProperty FindDefinedProperty(string propertyName, IEdmStructuredType owningStructuredType, ODataMessageReaderSettings messageReaderSettings)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(!string.IsNullOrEmpty(propertyName), "!string.IsNullOrEmpty(propertyName)");
            Debug.Assert(messageReaderSettings != null, "messageReaderSettings != null");

            if (owningStructuredType == null)
            {
                return null;
            }

            IEdmProperty property = owningStructuredType.FindProperty(propertyName);

            if (property == null && owningStructuredType.IsOpen)
            {
                if (messageReaderSettings.UndeclaredPropertyBehaviorKinds != ODataUndeclaredPropertyBehaviorKinds.None)
                {
                    throw new ODataException(Strings.ReaderValidationUtils_UndeclaredPropertyBehaviorKindSpecifiedForOpenType(propertyName, owningStructuredType.ODataFullName()));
                }
            }

            return property;
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:33,代码来源:ReaderValidationUtils.cs

示例8: ValidateAnnotationWithFewerPropertyThanType

        private void ValidateAnnotationWithFewerPropertyThanType(IEdmModel model, IEdmStructuredType actualType, IEnumerable<IEdmPropertyConstructor> annotationProperties)
        {
            foreach (var annotationProperty in annotationProperties)
            {
                var annotationName = annotationProperty.Name;
                var actualProperty = actualType.FindProperty(annotationName);
                Assert.IsNotNull(actualProperty, "Invalid property name.");

                Action<IEdmModel, IEdmStructuredType, IEnumerable<IEdmPropertyConstructor>> validateAnnotation = (m, t, l) => this.ValidateAnnotationWithFewerPropertyThanType(m, t, l);
                ValidateAnnotationProperty(model, actualProperty, annotationProperty, validateAnnotation);
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:VocabularyParsingTests.cs

示例9: ValidateAnnotationWithExactPropertyAsType

        private void ValidateAnnotationWithExactPropertyAsType(IEdmModel model, IEdmStructuredType actualType, IEnumerable<IEdmPropertyConstructor> annotationProperties)
        {
            Assert.AreEqual(actualType.Properties().Count(), annotationProperties.Count(), "Annotation does not have the same count of properties as it's declared type.");

            foreach (var annotationProperty in annotationProperties)
            {
                var annotationName = annotationProperty.Name;
                var actualProperty = actualType.FindProperty(annotationName);
                Assert.IsNotNull(actualProperty, "Invalid property name.");

                Action<IEdmModel, IEdmStructuredType, IEnumerable<IEdmPropertyConstructor>> validateAnnotation = (m, t, l) => this.ValidateAnnotationWithExactPropertyAsType(m, t, l);
                ValidateAnnotationProperty(model, actualProperty, annotationProperty, validateAnnotation);
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:14,代码来源:VocabularyParsingTests.cs

示例10: CompareMembers

        private static void CompareMembers(IEdmStructuredType edmEdmType, IEdmStructuredType dataWebEdmType, bool isReflectionBasedProvider, out int totalNavProps)
        {
            // find the number of nav properties on this type (not the base type). This will help us to determine how many associations 
            // be generated
            totalNavProps = edmEdmType.DeclaredProperties.OfType<IEdmNavigationProperty>().Count();
            AstoriaTestLog.IsTrue(edmEdmType.DeclaredProperties.Count() == dataWebEdmType.DeclaredProperties.Count(), "Number of members must match");

            foreach (IEdmProperty member1 in edmEdmType.DeclaredProperties)
            {
                IEdmProperty member2 = dataWebEdmType.FindProperty(member1.Name);
                AstoriaTestLog.IsNotNull(member2);

                // WCF DS server will always write DateTimeOffset as the data type, if the backend model has DateTime as the data type
                string edmMemberTypeName = member1.Type.FullName();
                if (edmMemberTypeName == "Edm.DateTime")
                {
                    AstoriaTestLog.IsTrue(member2.Type.FullName() == "Edm.DateTimeOffset", "For DateTime properties in the model, we should generate");
                }
                else
                {
                    AstoriaTestLog.IsTrue(edmMemberTypeName == member2.Type.FullName(), "Type must match");
                }

                AstoriaTestLog.IsTrue(member1.Type.IsNullable == member2.Type.IsNullable, "nullability must match");

                // TODO: if its a navigation, compare referential constraint!
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:28,代码来源:MetadataUtil.cs


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