コード例 #1
0
ファイル: ExtensionMethods.cs プロジェクト: Netring/ILSpy
		/// <summary>
		/// Gets whether the type is an open type (contains type parameters).
		/// </summary>
		/// <example>
		/// <code>
		/// class X&lt;T&gt; {
		///   List&lt;T&gt; open;
		///   X&lt;X&lt;T[]&gt;&gt; open;
		///   X&lt;string&gt; 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;
		}
コード例 #2
0
 /// <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;
 }