Exemple #1
0
        public void PostNotification(NotificationInfo info)
        {
            if (string.IsNullOrEmpty(info.method))
            {
                MyDebug.Error("NotificationCenter::PostNotification => empty name sent to NotificationCenter.");
                return;
            }

            ArrayList listnerList = (ArrayList)_listnersData[info.method];

            if (null == listnerList && info.sender)
            {
                MyDebug.Warning("NotificationCenter::PostNotification => Method: " + info.method +
                                " Sent by: " + info.sender.name + " not found in listners data.");
                return;
            }
            else if (null == listnerList)
            {
                MyDebug.Warning("NotificationCenter::PostNotification => Method: " + info.method +
                                " not found in listners data.");
                return;
            }

            ArrayList observersToRemove = new ArrayList();

            foreach (Component listner in listnerList)
            {
                if (!listner)
                {
                    observersToRemove.Add(listner);
                }
                else
                {
                    listner.SendMessage(info.method, info.data, SendMessageOptions.DontRequireReceiver);
                }
            }

            foreach (object observer in observersToRemove)
            {
                listnerList.Remove(observer);
            }
        }