Skip to content

Commit

Permalink
fix: ensure types are instantiable
Browse files Browse the repository at this point in the history
  • Loading branch information
BeeHiveJava committed Sep 13, 2020
1 parent 974d808 commit cb1af58
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

namespace NetDaemon.Infrastructure.Extensions
{
public static class AssemblyExtensions
internal static class AssemblyExtensions
{
public static IEnumerable<Type> GetTypesWhereSubclassOf<T>(this Assembly assembly)
{
return assembly.GetTypes().Where(x => x.IsClass && x.IsSubclassOf(typeof(T)));
return assembly.GetTypes()
.Where(type => type.IsClass)
.Where(type => !type.IsGenericType)
.Where(type => !type.IsAbstract)
.Where(type => type.IsSubclassOf(typeof(T)));
}
}
}

0 comments on commit cb1af58

Please sign in to comment.