File tree Expand file tree Collapse file tree 4 files changed +44
-13
lines changed
RealTimeWeatherMonitoringApp/Presentation Expand file tree Collapse file tree 4 files changed +44
-13
lines changed 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+ using RealTimeWeatherMonitoringApp . Domain . Models ;
5+
6+ namespace RealTimeWeatherMonitoringApp . Presentation . Controller ;
7+
8+ public class ServerController
9+ {
10+ private readonly IDataChangeNotifier < WeatherData > _weatherDataNotifier ;
11+ private readonly IBotPublishingService _botPublishingService ;
12+ private readonly IBotEventManager < WeatherData > _weatherDataBotEventManager ;
13+
14+ public ServerController (
15+ IDataChangeNotifier < WeatherData > weatherDataNotifier ,
16+ IBotPublishingService botPublishingService ,
17+ IBotEventManager < WeatherData > weatherDataBotEventManager )
18+ {
19+ _weatherDataNotifier = weatherDataNotifier ;
20+ _botPublishingService = botPublishingService ;
21+ _weatherDataBotEventManager = weatherDataBotEventManager ;
22+ }
23+
24+ public void Start ( )
25+ {
26+ _weatherDataBotEventManager . Attach ( _weatherDataNotifier , _botPublishingService ) ;
27+ Console . WriteLine ( "Server:\t Bots are now listening for weather data..." ) ;
28+ Console . WriteLine ( "Server:\t [Tip] Use weather data processor to send data to the system." ) ;
29+ Console . WriteLine ( "Server:\t [Tip] Subscribe to bot notifications to receive any new events." ) ;
30+ Console . WriteLine ( new string ( '-' , 70 ) ) ;
31+ }
32+ }
Original file line number Diff line number Diff line change 11using RealTimeWeatherMonitoringApp . Application . Interfaces . Service ;
22using RealTimeWeatherMonitoringApp . Domain . Models ;
33
4- namespace RealTimeWeatherMonitoringApp . Presentation ;
4+ namespace RealTimeWeatherMonitoringApp . Presentation . Controller ;
55
66public class UserController
77{
@@ -21,9 +21,15 @@ public void Start()
2121 _botNotificationService . OnBotNotification += ( _ , args ) =>
2222 Console . WriteLine ( $ "\n { args . BotName } : { args . Message } ") ;
2323
24+ Console . WriteLine ( "User:\t Subscribed to bot notifications." ) ;
25+ Console . WriteLine ( "User:\t You can now enter weather data to process." ) ;
26+ Console . WriteLine ( "User:\t [Tip] No need to specify data format, the system auto detects it." ) ;
27+ Console . WriteLine ( "User:\t [Tip] Enter (q) to quit." ) ;
28+
2429 while ( true )
2530 {
26- Console . WriteLine ( "\n Enter weather data, or (q) to quit:" ) ;
31+ Console . WriteLine ( new string ( '-' , 70 ) ) ;
32+ Console . WriteLine ( "User: Enter weather data to process." ) ;
2733
2834 var input = Console . ReadLine ( ) ?? string . Empty ;
2935 if ( input . Equals ( "q" , StringComparison . CurrentCultureIgnoreCase ) ) break ;
Original file line number Diff line number Diff line change 11using Microsoft . Extensions . DependencyInjection ;
2- using RealTimeWeatherMonitoringApp . Application . Interfaces ;
3- using RealTimeWeatherMonitoringApp . Application . Interfaces . Service ;
4- using RealTimeWeatherMonitoringApp . Domain . Interfaces . Service ;
5- using RealTimeWeatherMonitoringApp . Domain . Models ;
6- using RealTimeWeatherMonitoringApp . Presentation ;
2+ using RealTimeWeatherMonitoringApp . Presentation . Controller ;
73using RealTimeWeatherMonitoringApp . Presentation . Utility ;
84
95// Inject Dependencies
106var provider = DependencyInjector . CreateServiceProvider ( ) ;
117
12- // Initialize Bot Events
13- var weatherBotPublisher = provider . GetRequiredService < IBotPublishingService > ( ) ;
14- var weatherDataNotifier = provider . GetRequiredService < IDataChangeNotifier < WeatherData > > ( ) ;
15- var weatherEventManager = provider . GetRequiredService < IBotEventManager < WeatherData > > ( ) ;
16- weatherEventManager . Attach ( weatherDataNotifier , weatherBotPublisher ) ;
17-
188// Start
9+ provider . GetRequiredService < ServerController > ( ) . Start ( ) ;
1910provider . GetRequiredService < UserController > ( ) . Start ( ) ;
Original file line number Diff line number Diff line change 1111using RealTimeWeatherMonitoringApp . Infrastructure . Interfaces . Factory ;
1212using RealTimeWeatherMonitoringApp . Infrastructure . Repository ;
1313using RealTimeWeatherMonitoringApp . Infrastructure . Service ;
14+ using RealTimeWeatherMonitoringApp . Presentation . Controller ;
1415
1516namespace RealTimeWeatherMonitoringApp . Presentation . Utility ;
1617
@@ -72,5 +73,6 @@ private static void InjectApplication(IServiceCollection services)
7273 private static void InjectPresentation ( IServiceCollection services )
7374 {
7475 services . AddSingleton < UserController > ( ) ;
76+ services . AddSingleton < ServerController > ( ) ;
7577 }
7678}
You can’t perform that action at this time.
0 commit comments