方法一:

 var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(ISecurity))))
.ToArray();

 

方法二:

public static IEnumerable<Type> GetTypes(Type InterfaceType)
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
foreach (var type in assembly.GetTypes())
{
foreach (var t in type.GetInterfaces())
{
if (t == InterfaceType)
{
yield return type;
break;
}
}
}
}
}

相关文章:

  • 2021-08-18
  • 2022-12-23
  • 2021-11-12
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
  • 2021-12-28
  • 2021-07-03
  • 2022-12-23
  • 2021-11-10
相关资源
相似解决方案