Module.FilterTypeName 字段
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
一个 TypeFilter
对象,该对象根据名称筛选在此模块中定义的类型列表。 此字段区分大小写且为只读。
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
字段值
示例
以下示例显示与指定搜索条件匹配的模块名称。
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
注解
筛选器支持尾随“*”通配符。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈