zoukankan      html  css  js  c++  java
  • 反射

    static void  CheckBasePage()
            {
                Assembly assembly = Assembly.GetAssembly(typeof(BasePage));    
              
                Module module = assembly.ManifestModule;
                Type[] types = module.GetTypes();          
                foreach (Type t in types)
                {
                    try
                    {
                        if (t.IsSubclassOf(typeof(System.Web.UI.Page)))
                        {
                            if (!t.IsSubclassOf(typeof(BasePage)))
                            {
                                string aa = t.ToString() + "没有继承该类";
                                Console.WriteLine(aa);                           
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message + "-" + ex.StackTrace);
                    }

                }

                //Assembly a = Assembly.LoadFile(@" ");
                //Type[] type = a.GetTypes();
                //foreach (Type t in type)
                //{
                  
                //    try
                //    {
                      
                //        if (t.IsSubclassOf(typeof(System.Web.UI.Page)))
                //        {
                //            BasePage o = (BasePage)a.CreateInstance(t.FullName);
                //            object value = t.GetProperty("Guid").GetValue(o, null);
                //        }
                //    }
                //    catch
                //    { }
                //}
            }

  • 相关阅读:
    centos 7 pip install MySQL-python 报错
    修改centos history记录数上限
    CentOS 7 如何设置为eth0网卡
    字符串判空有空格报错:binary operator expected
    Linux指定用户运行程序
    MySQL 新建用户,为用户授权,指定用户访问数据库
    解决linux 中文乱码
    UNIX目录访问操作
    通过lseek产生空洞文件
    lseek系统调用
  • 原文地址:https://www.cnblogs.com/zwei1121/p/1004638.html
Copyright © 2011-2022 走看看