/// <summary> /// Gets whether the type is an open type (contains type parameters). /// </summary> /// <example> /// <code> /// class X<T> { /// List<T> open; /// X<X<T[]>> open; /// X<string> closed; /// int closed; /// } /// </code> /// </example> public static bool IsOpen(this IType type) { if (type == null) throw new ArgumentNullException("type"); TypeClassificationVisitor v = new TypeClassificationVisitor(); type.AcceptVisitor(v); return v.isOpen; }
/// <summary> /// Gets the entity that owns the type parameters occurring in the specified type. /// If both class and method type parameters are present, the method is returned. /// Returns null if the specified type is closed. /// </summary> /// <seealso cref="IsOpen"/> static IEntity GetTypeParameterOwner(IType type) { if (type == null) throw new ArgumentNullException("type"); TypeClassificationVisitor v = new TypeClassificationVisitor(); type.AcceptVisitor(v); return v.typeParameterOwner; }