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
} }
#endregion #endregion
#region IsOpen / IsUnbound #region IsOpen / IsUnbound / IsKnownType
sealed class TypeClassificationVisitor : TypeVisitor sealed class TypeClassificationVisitor : TypeVisitor
{ {
internal bool isOpen; internal bool isOpen;
@ -140,6 +140,16 @@ namespace ICSharpCode.NRefactory.TypeSystem
throw new ArgumentNullException("type"); throw new ArgumentNullException("type");
return type is ITypeDefinition && type.TypeParameterCount > 0; 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 #endregion
#region Import #region Import

Loading…
Cancel
Save