Skip to content

Commit ffbd535

Browse files
committed
Implement bots initializer
1 parent 11d731b commit ffbd535

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using RealTimeWeatherMonitoringApp.Domain.Models;
2+
3+
namespace RealTimeWeatherMonitoringApp.Infrastructure.Interfaces;
4+
5+
/// <typeparam name="TEvaluated">Determines the type of bots to initialize, and what data they evaluate</typeparam>
6+
public interface IBotInitializer<TEvaluated>
7+
{
8+
IEnumerable<Bot<TEvaluated>> InitializeAndGetAllBots();
9+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using RealTimeWeatherMonitoringApp.Domain.Models;
2+
using RealTimeWeatherMonitoringApp.Infrastructure.Interfaces;
3+
using RealTimeWeatherMonitoringApp.Infrastructure.Interfaces.Factory;
4+
5+
namespace RealTimeWeatherMonitoringApp.Infrastructure.Service;
6+
7+
public class BotInitializer<TEvaluated> : IBotInitializer<TEvaluated>
8+
{
9+
private readonly Lazy<IEnumerable<Bot<TEvaluated>>> _bots;
10+
11+
public BotInitializer(IConfigurationFactory configurationFactory, IBotFactory<TEvaluated> botFactory)
12+
{
13+
_bots = new Lazy<IEnumerable<Bot<TEvaluated>>>(() => configurationFactory
14+
.CreateBotConfigurations()
15+
.Select(botFactory.CreateBot));
16+
}
17+
18+
public IEnumerable<Bot<TEvaluated>> InitializeAndGetAllBots() => _bots.Value;
19+
}

0 commit comments

Comments
 (0)