11using Microsoft . Extensions . DependencyInjection ;
2+ using RealTimeWeatherMonitoringApp . Application . Interfaces ;
3+ using RealTimeWeatherMonitoringApp . Application . Interfaces . Service ;
4+ using RealTimeWeatherMonitoringApp . Application . Service ;
5+ using RealTimeWeatherMonitoringApp . Domain . Interfaces . Repository ;
6+ using RealTimeWeatherMonitoringApp . Domain . Interfaces . Service ;
7+ using RealTimeWeatherMonitoringApp . Domain . Models ;
8+ using RealTimeWeatherMonitoringApp . Domain . Service ;
9+ using RealTimeWeatherMonitoringApp . Infrastructure . Factory ;
10+ using RealTimeWeatherMonitoringApp . Infrastructure . Interfaces ;
11+ using RealTimeWeatherMonitoringApp . Infrastructure . Interfaces . Factory ;
12+ using RealTimeWeatherMonitoringApp . Infrastructure . Parsers ;
13+ using RealTimeWeatherMonitoringApp . Infrastructure . Repository ;
14+ using RealTimeWeatherMonitoringApp . Infrastructure . Service ;
215
316namespace RealTimeWeatherMonitoringApp . Presentation ;
417
@@ -7,11 +20,47 @@ public static class DependencyInjector
720 public static IServiceProvider CreateServiceProvider ( )
821 {
922 var services = new ServiceCollection ( ) ;
10- Inject ( services ) ;
23+ InjectInfrastructure ( services ) ;
24+ InjectDomain ( services ) ;
25+ InjectApplication ( services ) ;
1126 return services . BuildServiceProvider ( ) ;
1227 }
1328
14- private static void Inject ( ServiceCollection services )
29+ private static void InjectInfrastructure ( IServiceCollection services )
1530 {
31+ services . AddSingleton < IConfigurationFactory , ConfigurationFactory > ( ) ;
32+ services . AddSingleton < IEvaluatorFactory < WeatherData > , WeatherEvaluatorFactory > ( ) ;
33+ services . AddSingleton < IBotFactory < WeatherData > , BotFactory < WeatherData > > ( ) ;
34+ services . AddSingleton < IBotInitializer < WeatherData > , BotInitializer < WeatherData > > ( ) ;
35+ }
36+
37+ private static void InjectDomain ( IServiceCollection services )
38+ {
39+ services . AddSingleton < IBotRepository < WeatherData > , BotRepository < WeatherData > > ( ) ;
40+ services . AddSingleton < IBotControllerService < WeatherData > , BotControllerService < WeatherData > > ( ) ;
41+ }
42+
43+ private static void InjectApplication ( IServiceCollection services )
44+ {
45+ services . AddSingleton < IAutoParsingService < WeatherData > > ( _ =>
46+ {
47+ var service = new AutoParsingService < WeatherData > ( ) ;
48+ service . AddStrategy ( new WeatherDataJsonParser ( ) ) ;
49+ service . AddStrategy ( new WeatherDataXmlParser ( ) ) ;
50+ return service ;
51+ } ) ;
52+
53+ services . AddSingleton < MonitoringService < WeatherData > > ( ) ;
54+ services . AddSingleton < IDataReceiver < WeatherData > > (
55+ p => p . GetRequiredService < MonitoringService < WeatherData > > ( ) ) ;
56+ services . AddSingleton < IDataChangeNotifier < WeatherData > > (
57+ p => p . GetRequiredService < MonitoringService < WeatherData > > ( ) ) ;
58+
59+ services . AddSingleton < BotEventDispatcher > ( ) ;
60+ services . AddSingleton < IBotPublishingService > ( p => p . GetRequiredService < BotEventDispatcher > ( ) ) ;
61+ services . AddSingleton < IBotNotificationService > ( p => p . GetRequiredService < BotEventDispatcher > ( ) ) ;
62+
63+ services . AddSingleton < IBotEventManager < WeatherData > , BotEventManager < WeatherData > > ( ) ;
64+ services . AddSingleton < IDataProcessingService < WeatherData > , DataProcessingService < WeatherData > > ( ) ;
1665 }
1766}
0 commit comments