zoukankan      html  css  js  c++  java
  • Implementations of interface through Reflection 反射根据继承的信息查找指定的类

     1     /// <summary>
     2     /// Returns all types in the current AppDomain implementing the interface or inheriting the type. 
     3     /// </summary>
     4     public static IEnumerable<Type> TypesImplementingInterface(Type desiredType)
     5     {
     6         return AppDomain
     7             .CurrentDomain
     8             .GetAssemblies()
     9             .SelectMany(assembly => assembly.GetTypes())
    10             .Where(type => desiredType.IsAssignableFrom(type));
    11 
    12     }
        public static bool IsRealClass(Type testType)
        {
            return testType.IsAbstract == false
                && testType.IsGenericTypeDefinition == false
                && testType.IsInterface == false;
        }
  • 相关阅读:
    dbcp 详细配置
    InetAddress
    Qrcode 二维码
    左值右值分析
    javaweb reponse 写出文件
    ehcache 在集群环境下 出现 Cause was not due to an IOException or NotBoundException
    lo4j 日志级别
    log4j xml配置
    cron 表达式
    RabbitMQ简介
  • 原文地址:https://www.cnblogs.com/jinzhao/p/2288885.html
Copyright © 2011-2022 走看看