/// <summary> /// Determines whether the supplied CodeTypeRef represents a primitive .NET type, e.g., /// byte, bool, float, etc. /// </summary> public static bool IsPrimitive(this CodeTypeRef codeTypeRef) { // A possible optimization would be checking codeTypeRef.TypeKind for known primitive // types, e.g., vsCMTypeRef.vsCMTypeRefDouble. Consider adding this logic in future. return(_primitiveTypes.Any(primitiveType => codeTypeRef.IsType(primitiveType))); }
/// <summary> /// Determines whether the supplied CodeTypeRef represents the specified .NET type. /// This requires that the CodeTypeRef be attached to a parent code element so we can detect /// what language it is written in; otherwise we'll throw an InvalidOperationException. /// </summary> public static bool IsType <T>(this CodeTypeRef codeTypeRef) { return(codeTypeRef.IsType(typeof(T))); }