• 反射相关


    通过反射动态调用dll中的方法代码
    public class CMSMemCache
    {
            static Assembly _CMSMemCacheAssembly = null;
            static Type _CMSMemCacheType = null;
    
            static CMSMemCache()
            {
                _CMSMemCacheAssembly = Assembly.Load(new AssemblyName("CeairPortal.B2E.Components"));//加载程序集
                _CMSMemCacheType = _CMSMemCacheAssembly.GetType("CeairPortal.B2E.Components.MemCached.MemHandler");
            }
    
            public static void SetForFunCode(string memCode, object obj, params string[] funCode)
            {
                string[] c = funCode;
                MethodInfo method = _CMSMemCacheType.GetMethod("SetForFunCode");
                method.Invoke(_CMSMemCacheType, new object[] { memCode, obj, c });
            }
    }
    
    System.Reflection命名空间
    (1)   AppDomain:应用程序域,可以将其理解为一组程序集的逻辑容器
    (2)   Assembly:程序集类
    (3)   Module:模块类
    (4)   Type:使用反射得到类型信息的最核心的类
    他们之间是一种从属关系,也就是说,一个AppDomain可以包含N个Assembly,一个Assembly可以包含N个Module,而一个Module可以包含N个Type
  • 相关阅读:
    设计模式:组合模式
    对技术的认识及思考
    设计模式:策略模式
    java集合:常用集合的数据结构
    设计模式:代理模式
    java反射
    Spring事务管理
    在Spring使用junit注解进行单元测试
    tomcat限制ip访问
    获取openid回调两次
  • 原文地址:https://www.cnblogs.com/zhangchen/p/2498914.html
Copyright © 2020-2023  润新知