/// <summary> /// 添加消息处理器 /// </summary> /// <typeparam name="M"></typeparam> /// <param name="reusable"></param> public void AddGCMsgHandler <M>(GCMsgHandler <M> handlerFunc, bool reusable) where M : BaseGCMsg { if (handlerFunc == null) { // 如果参数对象为空, // 则直接退出! return; } // 获取类型关键字 System.Type K = typeof(M); // 获取内置字典 IDictionary <Delegate, WrappedGCMsgH> innerDict = this._handlerDict.ContainsKey(K) ? this._handlerDict[K] : null; if (innerDict == null) { // 如果内置字典为空, // 则新建字典! innerDict = new Dictionary <Delegate, WrappedGCMsgH>(); this._handlerDict[K] = innerDict; } // 设置处理器 innerDict[handlerFunc] = new WrappedGCMsgH( handlerFunc, reusable ); }
/// <summary> /// 添加消息处理器 /// </summary> /// <typeparam name="M"></typeparam> /// <param name="handlerFunc"></param> public void AddGCMsgHandler <M>(GCMsgHandler <M> handlerFunc) where M : BaseGCMsg { this.AddGCMsgHandler <M>(handlerFunc, false); }