开发者

Find all class names in a WPF project

In WPF, how do I use reflection to find all classes in a proj开发者_C百科ect? I'm interested in obtaining the ones whos names match a certain regular expression.


Something along the lines of

 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;

You can also load a specific assembly and filter the types you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜