mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-26 01:37:07 +00:00
25 lines
No EOL
735 B
C#
25 lines
No EOL
735 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
namespace NzbDrone.Common
|
|
{
|
|
public static class ReflectionExtensions
|
|
{
|
|
public static IEnumerable<Type> GetInterfaces(this Assembly assembly)
|
|
{
|
|
return assembly.GetTypes().Where(c => c.IsInterface);
|
|
}
|
|
|
|
public static IEnumerable<Type> GetImplementations(this Assembly assembly, Type contractType)
|
|
{
|
|
return assembly.GetTypes()
|
|
.Where(implementation =>
|
|
contractType.IsAssignableFrom(implementation) &&
|
|
!implementation.IsInterface &&
|
|
!implementation.IsAbstract
|
|
);
|
|
}
|
|
}
|
|
} |