Exemple #1
0
 public virtual void RemoveUiEventListener(string key)
 {
     if (UiEventsMap.ContainsKey(key))
     {
         UiEventsMap.Remove(key);
     }
 }
Exemple #2
0
 public void RemoveUiEventInterest(string key)
 {
     if (UiEventsMap.ContainsKey(key))
     {
         UiEventsMap.Remove(key);
     }
     MyView.RemoveUiEventListener(key);
 }
Exemple #3
0
        /// <inheritdoc />
        /// <summary>
        /// Called by the View. Handles UiEvent notification
        /// </summary>
        public virtual void HandleUiEvent(string key, object data)
        {
            Action <object> action;

            if (UiEventsMap.TryGetValue(key, out action))
            {
                action.Invoke(data);
            }
        }
Exemple #4
0
 public void RemoveUiEventInterest(string key, Action <object> action)
 {
     if (!UiEventsMap.ContainsKey(key))
     {
         return;
     }
     UiEventsMap[key] -= action;
     if (UiEventsMap[key].GetInvocationList().Length == 0)
     {
         RemoveUiEventInterest(key);
     }
 }
Exemple #5
0
 public void AddUiEventInterest(string key, Action <object> action)
 {
     if (UiEventsMap.ContainsKey(key))
     {
         UiEventsMap[key] += action;
     }
     else
     {
         UiEventsMap.Add(key, action);
         MyView.AddUiEventListener(key, this);
     }
 }
Exemple #6
0
        /// <inheritdoc />
        /// <summary>
        /// Handles UI event from UI/ViewModel. Looks for IMediators interested in the key
        /// </summary>
        /// <param name="key">Event key</param>
        /// <param name="body">Optional body</param>
        /// <returns>False if no one is interested</returns>
        public virtual bool HandleUiEvent(string key, object body)
        {
            IList <IMediator> mediators;

            if (UiEventsMap.TryGetValue(key, out mediators))
            {
                foreach (var m in mediators)
                {
                    m.HandleUiEvent(key, body);
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Exemple #7
0
        public virtual void AddUiEventListener(string key, IMediator mediator)
        {
            IList <IMediator> mediators;

            if (UiEventsMap.TryGetValue(key, out mediators))
            {
                if (!mediators.Contains(mediator))
                {
                    UiEventsMap[key].Add(mediator);
                }
            }
            else
            {
                UiEventsMap.Add(key, new List <IMediator> {
                    mediator
                });
            }
        }