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);
}
精彩评论