zoukankan      html  css  js  c++  java
  • 反射相关

    通过反射动态调用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
  • 相关阅读:
    别让你的生活止于平庸!(摘)
    NSURLSession 请求
    第三方原理
    iOS实用的小技巧
    简书APP
    网络请求
    JQuery 简介
    struts2拦截器的实现原理及源码剖析
    hibernate配置文件注意点
    hibernate中三种状态
  • 原文地址:https://www.cnblogs.com/zhangchen/p/2498914.html
Copyright © 2011-2022 走看看