zoukankan      html  css  js  c++  java
  • [原创]获取委托链方式,用于多播委托。

    今天研究了一下获取委托链的方式,发现通过Events只能获取特定事件的委托,对于一些自定义或者非事件类的委托不完全有效,下面是我的研究成果:

            public static Delegate[] GetDelegate<T>(this T t, string strDelegateName)
            {
                FieldInfo fieldInfo = typeof(T).GetField(strDelegateName,
                    BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                if (fieldInfo == null) return null;


                object o = fieldInfo.GetValue(t);
                MulticastDelegate dele = o as MulticastDelegate;
                if (o == null) return null;
                return dele.GetInvocationList();
            }

  • 相关阅读:
    01-节点层次
    WebAPI02
    WebAPI01
    牛客剑指Offer7
    Python字典排序
    Python字典中的键映射多个值
    计算机硬件的主要技术指标
    计算机的基本组成
    计算机系统概论
    数据库概论
  • 原文地址:https://www.cnblogs.com/hehexiaoxia/p/MulticaseDelegate.html
Copyright © 2011-2022 走看看