本文整理汇总了C#中IType.TypeEquals方法的典型用法代码示例。如果您正苦于以下问题:C# IType.TypeEquals方法的具体用法?C# IType.TypeEquals怎么用?C# IType.TypeEquals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IType
的用法示例。
在下文中一共展示了IType.TypeEquals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsDerivedFrom
/// <summary>
/// </summary>
/// <param name="thisType">
/// </param>
/// <param name="type">
/// </param>
/// <returns>
/// </returns>
public static bool IsDerivedFrom(this IType thisType, IType type)
{
Debug.Assert(type != null, "type is null");
if (thisType.Equals(type))
{
return false;
}
var t = thisType.BaseType;
while (t != null)
{
if (type.TypeEquals(t))
{
return true;
}
t = t.BaseType;
}
if (type.IsObject)
{
return true;
}
return false;
}
示例2: WriteFunctionCallProlog
/// <summary>
/// </summary>
/// <param name="methodInfo">
/// </param>
/// <param name="opCodeMethodInfo">
/// </param>
/// <param name="isVirtual">
/// </param>
/// <param name="hasThis">
/// </param>
/// <param name="llvmWriter">
/// </param>
/// <param name="thisType">
/// </param>
/// <param name="hasThisArgument">
/// </param>
/// <param name="opCodeFirstOperand">
/// </param>
/// <param name="resultOfFirstOperand">
/// </param>
/// <param name="isIndirectMethodCall">
/// </param>
/// <param name="ownerOfExplicitInterface">
/// </param>
/// <param name="requiredType">
/// </param>
public static void WriteFunctionCallProlog(
this IMethod methodInfo,
OpCodePart opCodeMethodInfo,
bool isVirtual,
bool hasThis,
LlvmWriter llvmWriter,
out IType thisType,
out bool hasThisArgument,
out OpCodePart opCodeFirstOperand,
out BaseWriter.ReturnResult resultOfFirstOperand,
out bool isIndirectMethodCall,
out IType ownerOfExplicitInterface,
out IType requiredType)
{
thisType = methodInfo.DeclaringType.ToClass();
hasThisArgument = hasThis && opCodeMethodInfo.OpCodeOperands != null
&& opCodeMethodInfo.OpCodeOperands.Length - methodInfo.GetParameters().Count() > 0;
opCodeFirstOperand = opCodeMethodInfo.OpCodeOperands != null && opCodeMethodInfo.OpCodeOperands.Length > 0
? opCodeMethodInfo.OpCodeOperands[0]
: null;
resultOfFirstOperand = opCodeFirstOperand != null ? llvmWriter.ResultOf(opCodeFirstOperand) : null;
isIndirectMethodCall = isVirtual
&&
(methodInfo.IsAbstract || methodInfo.IsVirtual ||
(thisType.IsInterface && thisType.TypeEquals(resultOfFirstOperand.Type)));
ownerOfExplicitInterface = isVirtual && thisType.IsInterface &&
thisType.TypeNotEquals(resultOfFirstOperand.Type)
? resultOfFirstOperand.Type
: null;
var rollbackType = false;
requiredType = ownerOfExplicitInterface != null ? resultOfFirstOperand.Type : null;
if (requiredType != null)
{
thisType = requiredType;
rollbackType = true;
}
if (isIndirectMethodCall && methodInfo.DeclaringType.TypeNotEquals(thisType) &&
methodInfo.DeclaringType.IsInterface && !thisType.IsInterface
&& thisType.HasExplicitInterfaceMethodOverride(methodInfo))
{
// this is explicit call of interface
isIndirectMethodCall = false;
}
else if (rollbackType)
{
thisType = methodInfo.DeclaringType;
}
}