开发者

Reflect Project Solution at design-time

Good night guys, i have a little problem ...

For my current project, i must reflect the whole solution on each type which inherits "IPropertyValidator".

Is there any way to reflect the solution at design-time?

I just tried it this way. VS hangs for a second on loading, but there are no results:

            PossibleValidatorTypes = new List<Type>();

        foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
        {
            foreach (Type type in assembly.GetTypes())
            {
                if (type.IsSubclassOf(typeof(IPropertyValidator)))
                    PossibleVal开发者_JS百科idatorTypes.Add(type);
            }
        }

How could i do this?

Thanks a lot :)


You can try that:

foreach (Type type in assembly.GetTypes())
            {
                if (typeof(IPropertyValidator).IsAssignableFrom (type))
                    PossibleValidatorTypes.Add(type);
            }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜