Added not supported types example.

Classes that has no empty parameters are not supported and not shown(activator can not create instances of them).
This commit is contained in:
Textus
2020-08-13 18:10:25 +03:00
parent 04c27fc3d4
commit 1e8f80077f
7 changed files with 70 additions and 5 deletions

View File

@ -51,6 +51,9 @@ public static class ManagedReferenceUtility
// Skip abstract classes because they should not be instantiated
if (type.IsAbstract)
continue;
// Skip types that has no public empty constructors (activator can not create them)
if (type.IsClass && type.GetConstructor(Type.EmptyTypes) == null) // Structs still can be created (strangely)
continue;
// Filter types by provided filters if there is ones
if (filters != null && filters.All(f => f == null || f.Invoke(type)) == false)
continue;