|
Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
|
Tradução
Original
|
Método Type.FindInterfaces
Namespace: System
Assembly: mscorlib (em mscorlib.dll)
Parâmetros
- filter
- Tipo: System.Reflection.TypeFilter
O representante que compara as interfaces com filterCriteria.
- filterCriteria
- Tipo: System.Object
Os critérios de pesquisa que determina se uma interface deve ser incluída na matriz retornada.
Valor de retorno
Tipo: System.Type[]Implementações
_Type.FindInterfaces(TypeFilter, Object)| Exceção | Condição |
|---|---|
| ArgumentNullException | |
| TargetInvocationException |
Observação |
|---|
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; } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Função Server Core sem suporte), Windows Server 2008 R2 (Função Server Core com suporte com o SP1 ou posterior, Itanium sem suporte)
O .NET Framework não oferece suporte a todas as versões de cada plataforma. Para obter uma lista das versões com suporte, consulte .Requisitos de sistema do NET Framework.
Observação