File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
RealTimeWeatherMonitoringApp/Application Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ using RealTimeWeatherMonitoringApp . Domain . Interfaces . Service ;
2+
3+ namespace RealTimeWeatherMonitoringApp . Application . Interfaces . Service ;
4+
5+ /// <summary>
6+ /// Responsible for attaching bots to events (e.g. publishers, notifiers)
7+ /// </summary>
8+ /// <typeparam name="TData">Data type that bots deal with</typeparam>
9+ public interface IBotEventManager < TData >
10+ {
11+ /// <summary>
12+ /// Sets up the event flow for bots by attaching them to a data change notifier and configuring them to publish their events
13+ /// through a specified publishing service. Bots will react to data changes notified by <paramref name="notifier"/> and
14+ /// their responses, if any, will be published to <paramref name="publisher"/>.
15+ /// </summary>
16+ /// <param name="notifier">Bots will subscribe to this notifier to receive updates on data changes relevant to their operations.</param>
17+ /// <param name="publisher">The publishing service through which bots can publish their events.</param>
18+ void Attach ( IDataChangeNotifier < TData > notifier , IBotPublishingService publisher ) ;
19+ }
Original file line number Diff line number Diff line change 1+ using RealTimeWeatherMonitoringApp . Application . Interfaces ;
2+ using RealTimeWeatherMonitoringApp . Application . Interfaces . Service ;
3+ using RealTimeWeatherMonitoringApp . Domain . Interfaces . Service ;
4+
5+ namespace RealTimeWeatherMonitoringApp . Application . Service ;
6+
7+ public class BotEventManager < TData > : IBotEventManager < TData >
8+ {
9+ private readonly IBotControllerService < TData > _botControllerService ;
10+
11+ public BotEventManager ( IBotControllerService < TData > botControllerService ) =>
12+ _botControllerService = botControllerService ;
13+
14+ public void Attach ( IDataChangeNotifier < TData > notifier , IBotPublishingService publisher )
15+ {
16+ var botControllers = _botControllerService . GetBotControllers ( publisher ) ;
17+ foreach ( var controller in botControllers )
18+ notifier . OnDataChange += ( _ , args ) => controller . React ( args ) ;
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments