Exemplo n.º 1
0
        /// <summary>
        /// Copies the cancellation status from <paramref name="sourceEvent"/> to <paramref name="targetEvent"/> and vice-versa.
        /// </summary>
        /// <param name="sourceEvent">Already triggered event.</param>
        /// <param name="targetEvent">Target event where the resulting cancellation should be copied to and from after publishing.</param>
        protected void WrapCancellableEvent(ICancellableEvent sourceEvent, ICancellableEvent targetEvent)
        {
            targetEvent.Cancelled = sourceEvent.Cancelled;

            this.eventAggregator.Publish(targetEvent);

            sourceEvent.Cancelled = targetEvent.Cancelled;
        }
Exemplo n.º 2
0
 void Distribute(ICancellableEvent e, IEnumerable <object> targets)
 {
     foreach (var component in targets.OfType <IComponent>())
     {
         if (!e.Propagating)
         {
             break;
         }
         component.Receive(e, this);
     }
 }
Exemplo n.º 3
0
 void Distribute(ICancellableEvent e, IList <Selection> hits)
 {
     foreach (var hit in hits)
     {
         if (!e.Propagating)
         {
             break;
         }
         var component = hit.Target as IComponent;
         component?.Receive(e, this);
     }
 }
Exemplo n.º 4
0
        public MessageHandlerResult HandleMessage(Message request)
        {
            IClient client = clientRepository.GetByID(request.clientId);

            ICancellableEvent subscribingEvent = PublishSubscribingEvent(request, client);

            if (subscribingEvent.Cancel)
            {
                Message subscriptionFailedResponse = GetSubscriptionFailedResponse(request, subscribingEvent.CancellationReason);
                return(new MessageHandlerResult {
                    Message = subscriptionFailedResponse, CanTreatAsLongPoll = false
                });
            }

            client.SubscribeTo(request.subscription);

            PublishSubscribedEvent(request, client);

            return(new MessageHandlerResult {
                Message = GetSubscriptionSucceededResponse(request), CanTreatAsLongPoll = false
            });
        }
Exemplo n.º 5
0
 protected object EmitCancellableReturnsObject(ICancellableEvent @event)
 {
     Emit(@event);
     return(@event.IsCancelled ? new object() : null);
 }
Exemplo n.º 6
0
 protected bool EmitCancellableReturnsBool(ICancellableEvent @event)
 {
     Emit(@event);
     return([email protected]);
 }