本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# CType.Equals方法的具体用法?C# CType.Equals怎么用?C# CType.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.CType
的用法示例。
在下文中一共展示了CType.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeContainsType
public static bool TypeContainsType(CType type, CType typeFind)
{
LRecurse: // Label used for "tail" recursion.
if (type == typeFind || type.Equals(typeFind))
return true;
switch (type.GetTypeKind())
{
default:
Debug.Assert(false, "Bad Symbol kind in TypeContainsType");
return false;
case TypeKind.TK_NullType:
case TypeKind.TK_VoidType:
case TypeKind.TK_OpenTypePlaceholderType:
// There should only be a single instance of these.
Debug.Assert(typeFind.GetTypeKind() != type.GetTypeKind());
return false;
case TypeKind.TK_ArrayType:
case TypeKind.TK_NullableType:
case TypeKind.TK_ParameterModifierType:
case TypeKind.TK_PointerType:
type = type.GetBaseOrParameterOrElementType();
goto LRecurse;
case TypeKind.TK_AggregateType:
{ // BLOCK
AggregateType ats = type.AsAggregateType();
for (int i = 0; i < ats.GetTypeArgsAll().Size; i++)
{
if (TypeContainsType(ats.GetTypeArgsAll().Item(i), typeFind))
return true;
}
}
return false;
case TypeKind.TK_ErrorType:
if (type.AsErrorType().HasParent())
{
ErrorType err = type.AsErrorType();
Debug.Assert(err.nameText != null && err.typeArgs != null);
for (int i = 0; i < err.typeArgs.Size; i++)
{
if (TypeContainsType(err.typeArgs.Item(i), typeFind))
return true;
}
if (err.HasTypeParent())
{
type = err.GetTypeParent();
goto LRecurse;
}
}
return false;
case TypeKind.TK_TypeParameterType:
return false;
}
}
示例2: SubstEqualTypes
public bool SubstEqualTypes(CType typeDst, CType typeSrc, TypeArray typeArgsCls, TypeArray typeArgsMeth, SubstTypeFlags grfst)
{
if (typeDst.Equals(typeSrc))
{
Debug.Assert(typeDst.Equals(SubstType(typeSrc, typeArgsCls, typeArgsMeth, grfst)));
return true;
}
var ctx = new SubstContext(typeArgsCls, typeArgsMeth, grfst);
return !ctx.FNop() && SubstEqualTypesCore(typeDst, typeSrc, ctx);
}
示例3: SubstEqualTypesCore
public bool SubstEqualTypesCore(CType typeDst, CType typeSrc, SubstContext pctx)
{
LRecurse: // Label used for "tail" recursion.
if (typeDst == typeSrc || typeDst.Equals(typeSrc))
{
return true;
}
switch (typeSrc.GetTypeKind())
{
default:
Debug.Assert(false, "Bad Symbol kind in SubstEqualTypesCore");
return false;
case TypeKind.TK_NullType:
case TypeKind.TK_VoidType:
case TypeKind.TK_OpenTypePlaceholderType:
// There should only be a single instance of these.
Debug.Assert(typeDst.GetTypeKind() != typeSrc.GetTypeKind());
return false;
case TypeKind.TK_ArrayType:
if (typeDst.GetTypeKind() != TypeKind.TK_ArrayType || typeDst.AsArrayType().rank != typeSrc.AsArrayType().rank)
return false;
goto LCheckBases;
case TypeKind.TK_ParameterModifierType:
if (typeDst.GetTypeKind() != TypeKind.TK_ParameterModifierType ||
((pctx.grfst & SubstTypeFlags.NoRefOutDifference) == 0 &&
typeDst.AsParameterModifierType().isOut != typeSrc.AsParameterModifierType().isOut))
return false;
goto LCheckBases;
case TypeKind.TK_PointerType:
case TypeKind.TK_NullableType:
if (typeDst.GetTypeKind() != typeSrc.GetTypeKind())
return false;
LCheckBases:
typeSrc = typeSrc.GetBaseOrParameterOrElementType();
typeDst = typeDst.GetBaseOrParameterOrElementType();
goto LRecurse;
case TypeKind.TK_AggregateType:
if (typeDst.GetTypeKind() != TypeKind.TK_AggregateType)
return false;
{ // BLOCK
AggregateType atsSrc = typeSrc.AsAggregateType();
AggregateType atsDst = typeDst.AsAggregateType();
if (atsSrc.getAggregate() != atsDst.getAggregate())
return false;
Debug.Assert(atsSrc.GetTypeArgsAll().Size == atsDst.GetTypeArgsAll().Size);
// All the args must unify.
for (int i = 0; i < atsSrc.GetTypeArgsAll().Size; i++)
{
if (!SubstEqualTypesCore(atsDst.GetTypeArgsAll().Item(i), atsSrc.GetTypeArgsAll().Item(i), pctx))
return false;
}
}
return true;
case TypeKind.TK_ErrorType:
if (!typeDst.IsErrorType() || !typeSrc.AsErrorType().HasParent() || !typeDst.AsErrorType().HasParent())
return false;
{
ErrorType errSrc = typeSrc.AsErrorType();
ErrorType errDst = typeDst.AsErrorType();
Debug.Assert(errSrc.nameText != null && errSrc.typeArgs != null);
Debug.Assert(errDst.nameText != null && errDst.typeArgs != null);
if (errSrc.nameText != errDst.nameText || errSrc.typeArgs.Size != errDst.typeArgs.Size)
return false;
if (errSrc.HasTypeParent() != errDst.HasTypeParent())
{
return false;
}
if (errSrc.HasTypeParent())
{
if (errSrc.GetTypeParent() != errDst.GetTypeParent())
{
return false;
}
if (!SubstEqualTypesCore(errDst.GetTypeParent(), errSrc.GetTypeParent(), pctx))
{
return false;
}
}
else
{
if (errSrc.GetNSParent() != errDst.GetNSParent())
{
return false;
}
}
// All the args must unify.
//.........这里部分代码省略.........
示例4: AreTypesEqualForConversion
protected bool AreTypesEqualForConversion(CType pType1, CType pType2)
{
return pType1.Equals(pType2);
}