//添加对应消息的回馈调用 public void RegisterRespondFuncByMessageID(int messageID, funcMsgResopond func) { if (m_respondListByMessageID.Count == 0) { AddPropChangedNotify((int)MVCPropertyID.enMessageRespond, OnMessageRespond); m_respondListByMessageID.Add(messageID, func); } else { if (m_respondListByMessageID.ContainsKey(messageID)) { m_respondListByMessageID[messageID] = func; } else { m_respondListByMessageID.Add(messageID, func); } } }
public void OnMessageRespond(int objectID, int eventType, IPropertyObject obj, object eventObj) { if (!IsVisiable()) { return; } MessageRespond respond = (MessageRespond)eventObj; int respondCode = respond.RespondCode; funcMsgResopond func = null; if (m_respondListByRespondCode.TryGetValue(respondCode, out func)) { func(respond); } if (m_respondListByMessageID.TryGetValue(respond.MessageID, out func)) { func(respond); } }
Dictionary <int, funcMsgResopond> m_respondListByMessageID = new Dictionary <int, funcMsgResopond>(); //针对消息ID的回调函数 public void RegisterRespondFuncByRespondCode(int respondCode, funcMsgResopond func) { if (m_respondListByRespondCode.Count == 0) { AddPropChangedNotify((int)MVCPropertyID.enMessageRespond, OnMessageRespond); m_respondListByRespondCode.Add(respondCode, func); } else { if (m_respondListByRespondCode.ContainsKey(respondCode)) { m_respondListByRespondCode[respondCode] = func; } else { m_respondListByRespondCode.Add(respondCode, func); } } }