Module.FindTypes メソッドとは? わかりやすく解説

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

モジュール内の 1 つ上のクラス読み込むことができません。

解説解説

ReflectionTypeLoadException特殊なクラス読み込み例外です。ReflectionTypeLoadException.Types プロパティは、モジュール定義され読み込まれクラス配列格納します。この配列には null 値が含まれる場合ありますReflectionTypeLoadException.LoaderExceptions プロパティは、クラス ローダースローした例外を表す例外配列です。クラス配列のすきまは、この例外合わせて並べられます。

モジュールクラスごとに、filter指定されデリゲートが、そのクラスを表す Type オブジェクト指定した filterCriteria渡され呼び出されます。filter特定のクラス返した場合は、返される配列にそのクラス格納されます。filternull 参照 (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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Module クラス
Module メンバ
System.Reflection 名前空間
FilterTypeName
FilterTypeNameIgnoreCase
ReflectionTypeLoadException



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Module.FindTypes メソッド」の関連用語

Module.FindTypes メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Module.FindTypes メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS