Type.FindInterfaces メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Public Overridable Function FindInterfaces ( _ filter As TypeFilter, _ filterCriteria As Object _ ) As Type()
Dim instance As Type Dim filter As TypeFilter Dim filterCriteria As Object Dim returnValue As Type() returnValue = instance.FindInterfaces(filter, filterCriteria)
戻り値
現在の Type によって実装または継承されたインターフェイスのフィルタ処理されたリストを表している Type オブジェクトの配列。フィルタに一致するインターフェイスが現在の Type によって実装または継承されていない場合は、型 Type の空の配列。


System.Reflection.TypeFilter デリゲートの代わりに、System.Reflection.Module クラスによって提供された Module.FilterTypeName デリゲートおよび Module.FilterTypeNameIgnoreCase デリゲートを使用することもできます。
このクラスによって実装されるすべてのインターフェイスは、基本クラスまたはこのクラス自体のどちらで宣言されている場合でも、検索時に検索対象として認識されます。
このメソッドは、基本クラス階層を検索し、各クラスが実装していて検索条件に一致した各インターフェイスと、それらの各インターフェイスが実装していて検索条件に一致したインターフェイスをすべて返します (つまり、検索条件に一致する、中間の階層にあるインターフェイスも返します)。重複するインターフェイスは返されません。
現在の Type がジェネリック型またはジェネリック メソッドの定義の型パラメータを表している場合、FindInterfaces は、型パラメータの制約内で宣言されたすべてのインターフェイス、および制約内で宣言されたインターフェイスで継承されたすべてのインターフェイスを検索します。現在の Type がジェネリック型の型引数を表している場合、FindInterfaces は、型によって実装されたすべてのインターフェイスを検索します。制約に一致するかどうかは関係ありません。
![]() |
---|
FindInterfaces は、ジェネリックではない型においてもジェネリック インターフェイスを返す場合があります。たとえば、非ジェネリック型が IEnumerable<int> (Visual Basic の場合は IEnumerable(Of Integer)) を実装する場合があります。 |

指定した型によって実装または継承される指定したインターフェイスを検索し、そのインターフェイス名を表示する例を次に示します。
Imports System Imports System.Xml Imports System.Reflection Imports Microsoft.VisualBasic Public Class MyFindInterfacesSample Public Shared Sub Main() Try Dim myXMLDoc As New XmlDocument() myXMLDoc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" _ & "<title>Pride And Prejudice</title>" & "</book>") Dim myType As Type = myXMLDoc.GetType() ' Specify the TypeFilter delegate that compares the ' interfaces against filter criteria. Dim myFilter As New TypeFilter(AddressOf MyInterfaceFilter) Dim myInterfaceList() As String = _ {"System.Collections.IEnumerable", _ "System.Collections.ICollection"} Dim index As Integer For index = 0 To myInterfaceList.Length - 1 Dim myInterfaces As Type() = _ myType.FindInterfaces(myFilter, myInterfaceList(index)) If myInterfaces.Length > 0 Then Console.WriteLine(ControlChars.Cr & _ "{0} implements the interface {1}.", _ myType, myInterfaceList(index)) Dim j As Integer For j = 0 To myInterfaces.Length - 1 Console.WriteLine("Interfaces supported: {0}", _ myInterfaces(j).ToString()) Next j Else Console.WriteLine(ControlChars.Cr & _ "{0} does not implement the interface {1}.", _ myType, myInterfaceList(index)) End If Next index Catch e As ArgumentNullException Console.WriteLine("ArgumentNullException: " & e.Message) Catch e As TargetInvocationException Console.WriteLine("TargetInvocationException: " & e.Message) Catch e As Exception Console.WriteLine("Exception: " & e.Message) End Try End Sub 'Main Public Shared Function MyInterfaceFilter(ByVal typeObj As Type, _ ByVal criteriaObj As [Object]) As Boolean If typeObj.ToString() = criteriaObj.ToString() Then Return True Else Return False End If End Function 'MyInterfaceFilter End Class 'MyFindInterfacesSample
using System; using System.Xml; using System.Reflection; public class MyFindInterfacesSample { public static void Main() { try { XmlDocument myXMLDoc = new XmlDocument(); myXMLDoc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>"); Type myType = myXMLDoc.GetType(); // Specify the TypeFilter delegate that compares the // interfaces against filter criteria. TypeFilter myFilter = new TypeFilter(MyInterfaceFilter); String[] myInterfaceList = new String[2] {"System.Collections.IEnumerable", "System.Collections.ICollection"}; for(int index=0; index < myInterfaceList.Length; index++) { Type[] myInterfaces = myType.FindInterfaces(myFilter, myInterfaceList[index]); if (myInterfaces.Length > 0) { Console.WriteLine("\n{0} implements the interface {1}." , myType, myInterfaceList[index]); for(int j =0;j < myInterfaces.Length;j++) Console.WriteLine("Interfaces supported: {0}." , myInterfaces[j].ToString()); } else Console.WriteLine( "\n{0} does not implement the interface {1}.", myType,myInterfaceList[index]); } } catch(ArgumentNullException e) { Console.WriteLine("ArgumentNullException: " + e.Message); } catch(TargetInvocationException e) { Console.WriteLine("TargetInvocationException: " + e.Message); } catch(Exception e) { Console.WriteLine("Exception: " + e.Message); } } public static bool MyInterfaceFilter(Type typeObj,Object criteriaObj) { if(typeObj.ToString() == criteriaObj.ToString()) return true; else return false; } }
#using <system.xml.dll> using namespace System; using namespace System::Xml; using namespace System::Reflection; public ref class MyFindInterfacesSample { public: static bool MyInterfaceFilter(Type^ typeObj, Object^ criteriaObj) { if(typeObj->ToString()->Equals(criteriaObj->ToString())) return true; else return false; } }; int main() { try { XmlDocument^ myXMLDoc = gcnew XmlDocument; myXMLDoc->LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title> </book>"); Type^ myType = myXMLDoc->GetType(); // Specify the TypeFilter delegate that compares the interfaces // against filter criteria. TypeFilter^ myFilter = gcnew TypeFilter( MyFindInterfacesSample::MyInterfaceFilter); array<String^>^myInterfaceList = {"System.Collections.IEnumerable" , "System.Collections.ICollection"}; for(int index = 0; index < myInterfaceList->Length; index++) { array<Type^>^myInterfaces = myType->FindInterfaces( myFilter, myInterfaceList[index]); if(myInterfaces->Length > 0) { Console::WriteLine("\n{0} implements the interface {1}.", myType, myInterfaceList[index]); for(int j = 0; j < myInterfaces->Length; j++) Console::WriteLine("Interfaces supported: {0}.", myInterfaces[j]); } else Console::WriteLine( "\n{0} does not implement the interface {1}.", myType, myInterfaceList[index]); } } catch(ArgumentNullException^ e) { Console::WriteLine("ArgumentNullException: {0}", e->Message); } catch(TargetInvocationException^ e) { Console::WriteLine("TargetInvocationException: {0}", e->Message); } catch(Exception^ e) { Console::WriteLine("Exception: {0}", e->Message); } }
import System.*; import System.Xml.*; import System.Reflection.*; public class MyFindInterfacesSample { public static void main(String[] args) { try { XmlDocument myXmlDoc = new XmlDocument(); myXmlDoc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + "<title>Pride And Prejudice</title>" + "</book>"); Type myType = myXmlDoc.GetType(); // Specify the TypeFilter delegate that compares the interfaces // against filter criteria. TypeFilter myFilter = new TypeFilter(MyInterfaceFilter); String myInterfaceList[] = new String[] { "System.Collections.IEnumerable", "System.Collections.ICollection" }; for (int index = 0; index < myInterfaceList.length; index++) { Type myInterfaces[] = myType.FindInterfaces(myFilter, myInterfaceList.get_Item(index)); if (myInterfaces.length > 0) { Console.WriteLine("\n{0} implements the interface {1}." , myType, myInterfaceList.get_Item(index)); for (int j = 0; j < myInterfaces.length; j++) { Console.WriteLine("Interfaces supported: {0}." , myInterfaces.get_Item(j).ToString()); } } else { Console.WriteLine("\n{0} does not implement the" + " interface {1}.", myType, myInterfaceList.get_Item(index)); } } } catch (ArgumentNullException e) { Console.WriteLine("ArgumentNullException: " + e.get_Message()); } catch (TargetInvocationException e) { Console.WriteLine("TargetInvocationException: " + e.get_Message()); } catch (System.Exception e) { Console.WriteLine("Exception: " + e.get_Message()); } } //main public static boolean MyInterfaceFilter(Type typeObj, Object criteriaObj) { if (typeObj.ToString().Equals(criteriaObj.ToString())) { return true; } else { return false; } } //MyInterfaceFilter } //MyFindInterfacesSample

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_Type.FindInterfaces メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As _Type Dim filter As TypeFilter Dim filterCriteria As Object Dim returnValue As Type() returnValue = instance.FindInterfaces(filter, filterCriteria)
戻り値
現在の Type によって実装または継承されているインターフェイスのフィルタ適用済みリストを表す、Type オブジェクトの配列。 または フィルタ条件に一致するインターフェイスが現在の Type で実装または継承されていない場合は、Type 型の空の配列。

このメソッドは、アンマネージ コードからマネージ クラスにアクセスするためのメソッドであるため、マネージ コードからは呼び出さないでください。
Type.FindInterfaces メソッドは、現在の Type によって実装または継承されているインターフェイスのフィルタ適用済みリストを表す Type オブジェクトの配列を返します。

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からType.FindInterfacesを検索する場合は、下記のリンクをクリックしてください。

- Type.FindInterfacesのページへのリンク