Browse Source

Add IsKnownType() extension method.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
519dc12eda
  1. 12
      ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs

12
ICSharpCode.NRefactory/TypeSystem/ExtensionMethods.cs

@ -92,7 +92,7 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -92,7 +92,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
}
#endregion
#region IsOpen / IsUnbound
#region IsOpen / IsUnbound / IsKnownType
sealed class TypeClassificationVisitor : TypeVisitor
{
internal bool isOpen;
@ -140,6 +140,16 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -140,6 +140,16 @@ namespace ICSharpCode.NRefactory.TypeSystem
throw new ArgumentNullException("type");
return type is ITypeDefinition && type.TypeParameterCount > 0;
}
/// <summary>
/// Gets whether the type is the specified known type.
/// For generic known types, this returns true any parameterization of the type (and also for the definition itself).
/// </summary>
public static bool IsKnownType(this IType type, KnownTypeCode knownType)
{
var def = type.GetDefinition();
return def != null && def.KnownTypeCode == knownType;
}
#endregion
#region Import

Loading…
Cancel
Save