Skip to content

Commit 5855453

Browse files
committed
Implement PublisherBotController decorator
1 parent b2172c7 commit 5855453

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using RealTimeWeatherMonitoringApp.Domain.Common;
2+
using RealTimeWeatherMonitoringApp.Domain.Interfaces;
3+
using RealTimeWeatherMonitoringApp.Domain.Interfaces.Service;
4+
5+
namespace RealTimeWeatherMonitoringApp.Domain.Models.Controller;
6+
7+
/// <summary>
8+
/// A BotController that publishes its events to an IBotPublishingService
9+
/// </summary>
10+
public class PublisherBotController<TEvaluated> : IBotController<TEvaluated>
11+
{
12+
private readonly IBotController<TEvaluated> _botController;
13+
private readonly IBotPublishingService _publishingService;
14+
15+
public PublisherBotController(
16+
IBotController<TEvaluated> botController,
17+
IBotPublishingService publishingService)
18+
{
19+
_botController = botController;
20+
_publishingService = publishingService;
21+
}
22+
23+
public BotEventArgs? React(DataChangeEventArgs<TEvaluated> args)
24+
{
25+
var botEventArgs = _botController.React(args);
26+
if (botEventArgs != null)
27+
_publishingService.Publish(botEventArgs);
28+
return botEventArgs;
29+
}
30+
}

0 commit comments

Comments
 (0)