zoukankan      html  css  js  c++  java
  • 反射

     static void Main()
    {
    //LoadAssemblies();
    Func<Type, string> classnameAndBase = null;
    classnameAndBase = t => "-" + t.FullName + ((t.BaseType != typeof(object)) ? classnameAndBase(t.BaseType) : string.Empty);
    //定义查询,在当前AppDomain中加载的所有程序集中查找从exception派生的所有public类型
    var exceptionTree = (from a in AppDomain.CurrentDomain.GetAssemblies()
    from t in a.GetExportedTypes()
    where t.IsClass && t.IsPublic && typeof(Exception).IsAssignableFrom(t)
    let typeHierarchTemp = classnameAndBase(t).Split('-').Reverse().ToArray()
    let typeHierarchy = string.Join("-", typeHierarchTemp, 0, typeHierarchTemp.Length - 1)
    orderby typeHierarchy
    select typeHierarchy
    ).ToArray();
    Console.WriteLine("{0} 个异常类", exceptionTree.Count());
    foreach (string s in exceptionTree)
    {
    string[] x = s.Split('-');
    //根据基类型的数量进行缩进
    Console.WriteLine(new string(' ', 3 * (x.Length - 1)) + x[x.Length - 1]);
    }
    Console.ReadKey();
    }
  • 相关阅读:
    12.19手动 项目部署
    12.19 redis缓存
    12.19 redis缓存
    用压测模拟并发、并发处理(synchronized,redis分布式锁)
    12.19 异常捕获补充
    app提交版本更新的流程
    变量
    类型转换的判别
    本文档中使用的伪类型
    Callbacks
  • 原文地址:https://www.cnblogs.com/smailxiaobai/p/2317372.html
Copyright © 2011-2022 走看看