本文整理汇总了C#中ITypeSymbol.Inherits方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeSymbol.Inherits方法的具体用法?C# ITypeSymbol.Inherits怎么用?C# ITypeSymbol.Inherits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeSymbol
的用法示例。
在下文中一共展示了ITypeSymbol.Inherits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeHasWeakIdentity
private bool TypeHasWeakIdentity(ITypeSymbol type, SemanticModel model)
{
switch (type.TypeKind)
{
case TypeKind.ArrayType:
var arrayType = type as IArrayTypeSymbol;
return arrayType != null && arrayType.ElementType.IsPrimitiveType();
case TypeKind.Class:
case TypeKind.TypeParameter:
Compilation compilation = model.Compilation;
INamedTypeSymbol marshalByRefObjectTypeSymbol = compilation.GetTypeByMetadataName("System.MarshalByRefObject");
INamedTypeSymbol executionEngineExceptionTypeSymbol = compilation.GetTypeByMetadataName("System.ExecutionEngineException");
INamedTypeSymbol outOfMemoryExceptionTypeSymbol = compilation.GetTypeByMetadataName("System.OutOfMemoryException");
INamedTypeSymbol stackOverflowExceptionTypeSymbol = compilation.GetTypeByMetadataName("System.StackOverflowException");
INamedTypeSymbol memberInfoTypeSymbol = compilation.GetTypeByMetadataName("System.Reflection.MemberInfo");
INamedTypeSymbol parameterInfoTypeSymbol = compilation.GetTypeByMetadataName("System.Reflection.ParameterInfo");
INamedTypeSymbol threadTypeSymbol = compilation.GetTypeByMetadataName("System.Threading.Thread");
return
type.SpecialType == SpecialType.System_String ||
type.Equals(executionEngineExceptionTypeSymbol) ||
type.Equals(outOfMemoryExceptionTypeSymbol) ||
type.Equals(stackOverflowExceptionTypeSymbol) ||
type.Inherits(marshalByRefObjectTypeSymbol) ||
type.Inherits(memberInfoTypeSymbol) ||
type.Inherits(parameterInfoTypeSymbol) ||
type.Inherits(threadTypeSymbol);
// What about struct types?
default:
return false;
}
}
示例2: Inherits
private bool Inherits(ITypeSymbol symbol, ITypeSymbol baseType)
{
return symbol == null ? false : symbol.Inherits(baseType);
}