Ejemplo n.º 1
0
        public void Publish(MvxMessage message, Type messageType)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            List <BaseSubscription> toNotify = null;

            lock (this)
            {
                /*
                 *              MvxTrace.Trace("Found {0} subscriptions of all types", _subscriptions.Count);
                 *              foreach (var t in _subscriptions.Keys)
                 *              {
                 *                      MvxTrace.Trace("Found  subscriptions for {0}", t.Name);
                 *              }
                 */
                Dictionary <Guid, BaseSubscription> messageSubscriptions;
                if (_subscriptions.TryGetValue(messageType, out messageSubscriptions))
                {
                    //MvxTrace.Trace("Found {0} messages of type {1}", messageSubscriptions.Values.Count, typeof(TMessage).Name);
                    toNotify = messageSubscriptions.Values.ToList();
                }
            }

            if (toNotify == null || toNotify.Count == 0)
            {
                //MvxTrace.Trace("Nothing registered for messages of type {0}", messageType.Name);
                return;
            }

            var allSucceeded = true;

            foreach (var subscription in toNotify)
            {
                allSucceeded &= subscription.Invoke(message);
            }

            if (!allSucceeded)
            {
                //MvxTrace.Trace("One or more listeners failed - purge scheduled");
                SchedulePurge(messageType);
            }
        }
Ejemplo n.º 2
0
 public void Publish(MvxMessage message)
 {
     Publish(message, message.GetType());
 }
		private void FireMessage(MvxMessage message)
		{
			var messenger = Mvx.Resolve<IMvxMessenger>();
			messenger.Publish(message);
		}