本文整理汇总了C#中IEdmStructuredType.IsAssignableFrom方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmStructuredType.IsAssignableFrom方法的具体用法?C# IEdmStructuredType.IsAssignableFrom怎么用?C# IEdmStructuredType.IsAssignableFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmStructuredType
的用法示例。
在下文中一共展示了IEdmStructuredType.IsAssignableFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCommonBaseType
/// <summary>
/// Checks if the <paramref name="firstType"/> structured type and the <paramref name="secondType"/> structured type
/// have a common base type.
/// In other words, if <paramref name="secondType"/> is a subtype of <paramref name="firstType"/> or not.
/// </summary>
/// <param name="firstType">Type of the base type.</param>
/// <param name="secondType">Type of the sub type.</param>
/// <returns>The common base type or null if no common base type exists.</returns>
internal static IEdmStructuredType GetCommonBaseType(this IEdmStructuredType firstType, IEdmStructuredType secondType)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(firstType != null, "firstType != null");
Debug.Assert(secondType != null, "secondType != null");
if (firstType.IsEquivalentTo(secondType))
{
return firstType;
}
IEdmStructuredType commonBaseType = firstType;
while (commonBaseType != null)
{
if (commonBaseType.IsAssignableFrom(secondType))
{
return commonBaseType;
}
commonBaseType = commonBaseType.BaseType;
}
commonBaseType = secondType;
while (commonBaseType != null)
{
if (commonBaseType.IsAssignableFrom(firstType))
{
return commonBaseType;
}
commonBaseType = commonBaseType.BaseType;
}
return null;
}
示例2: GetCommonBaseType
internal static IEdmStructuredType GetCommonBaseType(this IEdmStructuredType firstType, IEdmStructuredType secondType)
{
IEdmStructuredType type;
if (firstType.IsEquivalentTo(secondType))
{
return firstType;
}
for (type = firstType; type != null; type = type.BaseType)
{
if (type.IsAssignableFrom(secondType))
{
return type;
}
}
for (type = secondType; type != null; type = type.BaseType)
{
if (type.IsAssignableFrom(firstType))
{
return type;
}
}
return null;
}