本文整理汇总了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;
}
示例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);
}
示例3: IsAssignableFrom
private static bool IsAssignableFrom(IEdmType candidateSupertype, IEdmType candidateSubtype)
{
return candidateSubtype.IsOrInheritsFrom(candidateSupertype);
}