查找WPF项目中的所有类名

luv*_*ere 1 c# reflection wpf class

在WPF中,如何使用反射来查找项目中的所有类?我有兴趣获得名称与某个正则表达式匹配的那些.

Yan*_*rtz 5

有点像

 var assemblies = AppDomain.CurrentDomain.GetAssemblies()
            .Where(a => a.GetName().Name.StartsWith("MyCompany"));

var types =         from asm in assemblies
                    from type in asm.GetTypes()
            where Regex.IsMatch(type.FullName,"MyRegexp")
            select type.Name;
Run Code Online (Sandbox Code Playgroud)

您还可以加载特定的程序集并过滤所需的类型.