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


C# IEdmType.IsOrInheritsFrom方法代码示例

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


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

示例1: TryCreateTypeNameSegment

        private bool TryCreateTypeNameSegment(ODataPathSegment previous, string identifier, string parenthesisExpression, IEdmType targetEdmType)
        {
            if (previous.TargetEdmType == null || targetEdmType == null)
            {
                return false;
            }

            // if the new type segment prevents any results from possibly being returned, then short-circuit and throw a 404.
            IEdmType previousEdmType = previous.TargetEdmType;
            Debug.Assert(previousEdmType != null, "previous.TargetEdmType != null");

            if (previousEdmType.TypeKind == EdmTypeKind.Collection)
            {
                previousEdmType = ((IEdmCollectionType)previousEdmType).ElementType.Definition;
            }

            if (!targetEdmType.IsOrInheritsFrom(previousEdmType) && !previousEdmType.IsOrInheritsFrom(targetEdmType))
            {
                throw ExceptionUtil.CreateBadRequestError(ODataErrorStrings.RequestUriProcessor_InvalidTypeIdentifier_UnrelatedType(targetEdmType.ODataFullName(), previousEdmType.ODataFullName()));
            }

            // We want the type of the type segment to be a collection if the previous segment was a collection
            IEdmType actualTypeOfTheTypeSegment = targetEdmType;

            if (previous.EdmType.TypeKind == EdmTypeKind.Collection)
            {
                // creating a new collection type here because the type in the request is just the item type, there is no user-provided collection type.
                var actualEntityTypeOfTheTypeSegment = actualTypeOfTheTypeSegment as IEdmEntityType;
                if (actualEntityTypeOfTheTypeSegment != null)
                {
                    actualTypeOfTheTypeSegment = new EdmCollectionType(new EdmEntityTypeReference(actualEntityTypeOfTheTypeSegment, false));
                }
                else
                {
                    throw new ODataException(Strings.PathParser_TypeCastOnlyAllowedAfterEntityCollection(identifier));
                }
            }

            var typeNameSegment = (ODataPathSegment)new TypeSegment(actualTypeOfTheTypeSegment, previous.TargetEdmNavigationSource)
            {
                Identifier = identifier,
                TargetKind = previous.TargetKind,
                SingleResult = previous.SingleResult,
                TargetEdmType = targetEdmType
            };

            this.parsedSegments.Add(typeNameSegment);

            // Key expressions are allowed on Type segments
            this.TryBindKeyFromParentheses(parenthesisExpression);

            return true;
        }
开发者ID:sleetaylor,项目名称:odata.net,代码行数:53,代码来源:ODataPathParser.cs

示例2: IsRelatedTo

 /// <summary>
 /// Check whether the two are properly related types
 /// </summary>
 /// <param name="first">the first type</param>
 /// <param name="second">the second type</param>
 /// <returns>Whether the two types are related.</returns>
 public static bool IsRelatedTo(IEdmType first, IEdmType second)
 {
     return second.IsOrInheritsFrom(first) || first.IsOrInheritsFrom(second);
 }
开发者ID:rossjempson,项目名称:odata.net,代码行数:10,代码来源:UriEdmHelpers.cs

示例3: IsAssignableFrom

 private static bool IsAssignableFrom(IEdmType candidateSupertype, IEdmType candidateSubtype)
 {
     return candidateSubtype.IsOrInheritsFrom(candidateSupertype);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:4,代码来源:MetadataUtil.cs


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