本文整理汇总了C#中IType.GetTypeDepth方法的典型用法代码示例。如果您正苦于以下问题:C# IType.GetTypeDepth方法的具体用法?C# IType.GetTypeDepth怎么用?C# IType.GetTypeDepth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.GetTypeDepth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLogicalTypeDepth
public int GetLogicalTypeDepth(IType type)
{
int depth = type.GetTypeDepth();
if (type.IsValueType) return depth - 1;
return depth;
}
示例2: GetMostGenericType
public IType GetMostGenericType(IType current, IType candidate)
{
if (null == current && null == candidate)
throw new ArgumentNullException("current", "Both 'current' and 'candidate' are null");
if (null == current)
return candidate;
if (null == candidate)
return current;
if (IsAssignableFrom(current, candidate))
return current;
if (IsAssignableFrom(candidate, current))
return candidate;
if (IsNumberOrBool(current) && IsNumberOrBool(candidate))
return GetPromotedNumberType(current, candidate);
if (IsCallableType(current) && IsCallableType(candidate))
return ICallableType;
if (current.IsClass && candidate.IsClass)
{
if (current == ObjectType || candidate == ObjectType)
return ObjectType;
if (current.GetTypeDepth() < candidate.GetTypeDepth())
return GetMostGenericType(current.BaseType, candidate);
return GetMostGenericType(current, candidate.BaseType);
}
return ObjectType;
}
示例3: GetMostGenericType
public IType GetMostGenericType(IType current, IType candidate)
{
if (current.IsAssignableFrom(candidate))
{
return current;
}
if (candidate.IsAssignableFrom(current))
{
return candidate;
}
if (IsNumberOrBool(current) && IsNumberOrBool(candidate))
{
return GetPromotedNumberType(current, candidate);
}
if (IsCallableType(current) && IsCallableType(candidate))
{
return ICallableType;
}
if (current.IsClass && candidate.IsClass)
{
if (current == ObjectType || candidate == ObjectType)
{
return ObjectType;
}
if (current.GetTypeDepth() < candidate.GetTypeDepth())
{
return GetMostGenericType(current.BaseType, candidate);
}
return GetMostGenericType(current, candidate.BaseType);
}
return ObjectType;
}