コード例 #1
0
 public void Invoke(EventConstants ev, object parameter)
 {
     if (_events.ContainsKey(ev))
     {
         foreach (var handler in _events[ev])
         {
             handler?.Invoke(parameter);
         }
     }
 }
コード例 #2
0
        public void EventConstants_EventHierarchies(Tuple <EventSourceType, Event> evntt)
        {
            //Arrange
            var evnt = evntt.Item2;

            //Act
            var result = EventConstants.GetNextEvents(evnt.SourceType);

            //Assert
            Assert.That(result, Is.Not.Null, $"The hierarchy should never return null {evnt.SourceType}");
        }
コード例 #3
0
        public void Add(EventConstants ev, Action <object> handler)
        {
            if (_events.ContainsKey(ev))
            {
                _events[ev].Add(handler);
            }
            else
            {
                var handlers = new List <Action <object> >();
                handlers.Add(handler);

                _events.Add(ev, handlers);
            }
        }
コード例 #4
0
        /// <summary>
        /// For the check events `ShouldContinue=true` indicates that the event should move onto the next task(s)
        /// and `ShouldContinue=false` indicates that we loop on the same event type.
        /// </summary>
        /// <param name="result"></param>
        /// <param name="previousEvent"></param>
        /// <returns></returns>
        public async Task CreateNextEvents(EventResult result, Event previousEvent)
        {
            // result.Succeeded is false only when the event errors and in that case we don't mark it errored and don't continue.
            if (!result.Succeeded)
            {
                await this.logger.LogVerboseAsync("Event failed. No Next Events.");

                return;
            }

            // Grab next types if result should continue, else repeat event type
            var nextTypes = result.ShouldContinue ? EventConstants.GetNextEvents(previousEvent.SourceType) : new[] { previousEvent.SourceType };

            // Convert previous source id to array
            var nextSourceIds = previousEvent.SourceId.HasValue ? new[] { previousEvent.SourceId.Value } : null;

            await this.logger.LogVerboseAsync($"Next event with types {nextTypes.Join("{0},{1}")}");

            // Create next events
            await this.eventSourceService.CreateNextEvents(nextSourceIds, nextTypes, EventSourceService.GetIncreasingDelay(previousEvent), previousEvent.Id, previousEvent.HourId);
        }
コード例 #5
0
        public async Task CreateNextEvents(EventResult result, Event previousEvent)
        {
            if (!result.Succeeded)
            {
                await this.logger.LogVerboseAsync("Event failed. No Next Events.");

                return;
            }

            // if the result is then we never create any next events
            if (!result.ShouldContinue)
            {
                return;
            }

            result.Types =
                (result.Types != null && result.Types.Any())
                                ? result.Types
                                : EventConstants.GetNextEvents(previousEvent.SourceType).ToList();
            await this.logger.LogVerboseAsync($"Next event source ids: {result?.SourceIds?.Join("{0},{1}")} and with types {result?.Types?.Join("{0},{1}")}; Previous event: {previousEvent.Id}");

            await this.eventSourceService.CreateNextEvents(result.SourceIds, result.Types, result.Delay, previousEvent.Id, previousEvent.HourId);
        }
コード例 #6
0
 void SubscribeToEventBus()
 {
     EventBus.ClientInstance.Subscribe(EventConstants.UpdateCharacterSheet(charaName.ToString()), UpdateInfo);
 }