开发者

Reflect Project Solution at design-time

开发者 https://www.devze.com 2023-02-28 13:55 出处:网络
Good night guys, i have a little problem ... For my current project, i must reflect the whole solution on each type which inherits \"IPropertyValidator\".

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

精彩评论

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