Пример #1
0
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 public void Invoke(CanonicalEvent @event)
 {
     foreach (EventAction action in actions)
     {
         action.Execute(@event);
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="@event"></param>
        /// 
        public override void Execute(CanonicalEvent @event)
        {
            LocalDataStoreSlot slot = Thread.GetNamedDataSlot(DataStore);
            List<CanonicalEvent> events = GetEventAggregate(slot);

            if (events == null)
            {
                events = new List<CanonicalEvent>();
                events.Add(@event);
                SetEventAggregate(slot, events);

                if (Logger.IsDebugEnabled)
                {
                    LogDebug("initializing buffer size: {0}.", max);
                }
            }
            else if (events.Count <= max)
            {
                events.Add(@event);
                if (Logger.IsDebugEnabled)
                {
                    LogDebug("buffering event: {0}", events.Count);
                }
            }
            else
            {
                if (Logger.IsInfoEnabled)
                {
                    LogInfo("flushing {0} events from buffer...", events.Count);
                }
                List<CanonicalEvent> clone = new List<CanonicalEvent>(events);
                Deliver(ProcessAggregateResult(clone));
                events.Clear();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="@event"></param>
        /// 
        public void Send(CanonicalEvent @event)
        {
            if (Logger.IsErrorEnabled)
            {
                LogError("receiver event streams do not send events.");
            }

            throw new NotSupportedException("receiver event streams do not send events.");
        }
Пример #4
0
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="genericEvent"></param>
        /// 
        public EventRuleContext(CanonicalEvent genericEvent)
        {
            if (genericEvent == null)
            {
                //throw new ArgumentNullException("genericEvent");
            }

            this.genericEvent = genericEvent;
        }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="@event"></param>
 /// 
 public void Send(CanonicalEvent @event)
 {
     channel.Send(@event);
 }
        /// <summary>
        /// 
        /// </summary>
        /// 
        /// <param name="@event"></param>
        /// 
        public void Send(CanonicalEvent @event)
        {
            if (@event == null)
            {
                if (Logger.IsWarnEnabled)
                {
                    LogWarn("channel received null event.");
                }
            }

            sender.Send(@event);
        }
 /// <summary>
 /// 
 /// </summary>
 /// 
 /// <param name="events"></param>
 /// 
 /// <returns></returns>
 /// 
 protected virtual CanonicalEvent ProcessAggregateResult(List<CanonicalEvent> events)
 {
     CanonicalEvent result = new CanonicalEvent();
     result.Payload = events;
     result.EventType = Event.AggregateType;
     return result;
 }