다음을 통해 공유


Module.FindTypes 메서드

지정한 필터 및 필터 조건으로 수용한 클래스 배열을 반환합니다.

네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Overridable Function FindTypes ( _
    filter As TypeFilter, _
    filterCriteria As Object _
) As Type()
‘사용 방법
Dim instance As Module
Dim filter As TypeFilter
Dim filterCriteria As Object
Dim returnValue As Type()

returnValue = instance.FindTypes(filter, filterCriteria)
public virtual Type[] FindTypes (
    TypeFilter filter,
    Object filterCriteria
)
public:
virtual array<Type^>^ FindTypes (
    TypeFilter^ filter, 
    Object^ filterCriteria
)
public Type[] FindTypes (
    TypeFilter filter, 
    Object filterCriteria
)
public function FindTypes (
    filter : TypeFilter, 
    filterCriteria : Object
) : Type[]

매개 변수

  • filter
    클래스를 필터링하는 데 사용하는 대리자입니다.
  • filterCriteria
    클래스를 필터링하는 데 사용하는 개체입니다.

반환 값

필터에서 사용된 클래스를 포함하는 Type 형식의 배열입니다.

예외

예외 형식 조건

ReflectionTypeLoadException

모듈에서 하나 이상의 클래스를 로드할 수 없는 경우

설명

ReflectionTypeLoadException은 특수한 클래스 로드 예외입니다. ReflectionTypeLoadException.Types 속성에는 모듈 내에 정의되었고 로드된 클래스 배열이 포함됩니다. 이 배열에는 일부 Null 값이 포함되어 있을 수 있습니다. ReflectionTypeLoadException.LoaderExceptions 속성은 클래스 로더에서 throw한 예외를 나타내는 예외 배열입니다. 클래스 배열의 구멍은 예외와 함께 정렬됩니다.

filter에 의해 지정된 대리자는 모듈 내의 각 클래스에 대해 호출되며 지정된 filterCriteria 이외에도 클래스를 나타내는 Type 개체를 전달합니다. filter가 특정 클래스를 반환하면 해당 클래스는 반환된 배열 내에 포함됩니다. filter가 Null 참조(Visual Basic의 경우 Nothing)을 반환하면 모든 클래스가 반환되며 filterCriteria은 무시됩니다.

FindTypes를 사용하여 배열과 같은 매개 변수가 있는 형식을 찾을 수 없습니다.

예제

다음 예제에서는 FindTypes 메서드의 사용법을 보여 줍니다.

Imports System
Imports System.Reflection

Namespace ReflectionModule_Examples
    Class MyMainClass
        Shared Sub Main()
            Dim moduleArray() As [Module]

            moduleArray = [Assembly].GetExecutingAssembly().GetModules(False)

            ' In a simple project with only one module, the module at index
            ' 0 will be the module containing these classes.
            Dim myModule As [Module] = moduleArray(0)

            Dim tArray() As Type

            tArray = myModule.FindTypes([Module].FilterTypeName, "My*")

            Dim t As Type
            For Each t In tArray
                Console.WriteLine("Found a module beginning with My*: {0}", t.Name)
            Next t
        End Sub 'Main
    End Class 'MyMainClass

    Class MySecondClass
    End Class 'MySecondClass

    ' This class does not fit the filter criteria My*.
    Class YourClass
    End Class 'YourClass
End Namespace 'ReflectionModule_Examples
using System;
using System.Reflection;

namespace ReflectionModule_Examples
{
    class MyMainClass
    {
        static void Main()
        {
            Module[] moduleArray;
            
            moduleArray = Assembly.GetExecutingAssembly().GetModules(false);
            
            // In a simple project with only one module, the module at index
            // 0 will be the module containing these classes.
            Module myModule = moduleArray[0];

            Type[] tArray;

            tArray = myModule.FindTypes(Module.FilterTypeName, "My*");
            
            foreach(Type t in tArray)
            {
                Console.WriteLine("Found a module beginning with My*: {0}.", t.Name);
            }
        }
    }

    class MySecondClass
    {
    }

    // This class does not fit the filter criteria My*.
    class YourClass
    {
    }
}
using namespace System;
using namespace System::Reflection;
using namespace System::Collections;
public ref class MySecondClass{};


// This class does not fit the filter criterion My*.
public ref class YourClass{};

int main()
{
   array<Module^>^moduleArray;
   moduleArray = Assembly::GetExecutingAssembly()->GetModules( false );
   
   // In a simple project with only one module, the module at index
   // 0 will be the module containing these classes.
   Module^ myModule = moduleArray[ 0 ];
   array<Type^>^tArray;
   tArray = myModule->FindTypes( Module::FilterTypeName, "My*" );
   IEnumerator^ myEnum = tArray->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Type^ t = safe_cast<Type^>(myEnum->Current);
      Console::WriteLine( "Found a module beginning with My*: {0}.", t->Name );
   }
}
package ReflectionModule_Examples;
 
import System.*;
import System.Reflection.*;

class MyMainClass
{

    public static void main(String[] args)
    {
        Module moduleArray[];
        moduleArray = Assembly.GetExecutingAssembly().GetModules(false);

        // In a simple project with only one module, the module at index
        // 0 will be the module containing these classes.
        Module myModule = (Module)moduleArray.get_Item(0);
        Type tArray[];
        tArray = myModule.FindTypes(Module.FilterTypeName, "My*");
        for (int iCtr = 0; iCtr < tArray.length; iCtr++) {
            Type t = tArray[iCtr];
            Console.WriteLine("Found a module beginning with My*: {0}.",
                t.get_Name());
        }
    } //main
} //MyMainClass

class MySecondClass
{
} //MySecondClass

// This class does not fit the filter criteria My*.
class YourClass
{
} //YourClass

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

Module 클래스
Module 멤버
System.Reflection 네임스페이스
FilterTypeName
FilterTypeNameIgnoreCase
ReflectionTypeLoadException