Module.FilterTypeName Pole
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
TypeFilter
Obiekt, który filtruje listę typów zdefiniowanych w tym module na podstawie nazwy. To pole ma wielkość liter i tylko do odczytu.
public: static initonly System::Reflection::TypeFilter ^ FilterTypeName;
public static readonly System.Reflection.TypeFilter FilterTypeName;
staticval mutable FilterTypeName : System.Reflection.TypeFilter
Public Shared ReadOnly FilterTypeName As TypeFilter
Wartość pola
Przykłady
W poniższym przykładzie przedstawiono nazwy modułów, które są zgodne z określonymi kryteriami wyszukiwania.
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 );
}
}
using System;
using System.Reflection;
namespace ReflectionModule_Examples
{
class MyMainClass
{
static void Main()
{
Module[] moduleArray;
moduleArray = typeof(MyMainClass).Assembly.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
{
}
}
Imports System.Reflection
Namespace ReflectionModule_Examples
Class MyMainClass
Shared Sub Main()
Dim moduleArray() As [Module]
moduleArray = GetType(MyMainClass).Assembly.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
End Class
Class MySecondClass
End Class
' This class does not fit the filter criteria My*.
Class YourClass
End Class
End Namespace 'ReflectionModule_Examples
Uwagi
Filtr obsługuje końcowe symbole wieloznaczne "*".
Dotyczy
Zobacz też
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla