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
                //    { }
                //}
            }

  • 相关阅读:
    修复 Visual Studio Error “No exports were found that match the constraint”
    RabbitMQ Config
    Entity Framework Extended Library
    Navisworks API 简单二次开发 (自定义工具条)
    NavisWorks Api 简单使用与Gantt
    SQL SERVER 竖表变成横表
    SQL SERVER 多数据导入
    Devexpress GridControl.Export
    mongo DB for C#
    Devexress XPO xpPageSelector 使用
  • 原文地址:https://www.cnblogs.com/zwei1121/p/1004638.html
Copyright © 2011-2022 走看看