File tree Expand file tree Collapse file tree 4 files changed +62
-1
lines changed
backend/ServiceSimulation Expand file tree Collapse file tree 4 files changed +62
-1
lines changed Original file line number Diff line number Diff line change 88
99 <ItemGroup >
1010 <Folder Include =" Entities\" />
11- <Folder Include =" Services\" />
1211 </ItemGroup >
1312
1413</Project >
Original file line number Diff line number Diff line change 1+ using Bll . Domain . Interfaces ;
2+
3+ namespace Bll . Domain . Entities ;
4+
5+ public class TimeProvider : ITimeProvider
6+ {
7+ public DateTime Now { get ; } = DateTime . Now ;
8+ }
Original file line number Diff line number Diff line change 1+ using Api . enums ;
2+ using Bll . Domain . Interfaces ;
3+
4+ namespace Bll . Domain . Services ;
5+
6+ public class SimulationService : ISimulationService
7+ {
8+ private readonly ISource _source ;
9+ private readonly IBuffer _buffer ;
10+ private readonly IDevice _device ;
11+
12+ public SimulationService ( ISource source , IBuffer buffer , IDevice device )
13+ {
14+ _source = source ;
15+ _buffer = buffer ;
16+ _device = device ;
17+ }
18+
19+ public void StartSimulation ( SimulationType simulationType )
20+ {
21+ // TODO CHOSE NUMBER OF SOURCES, SIZE OF BUFFER, NUMBER OF DEVICES.
22+
23+ // TODO ALGORITHM OF CHOOSING REQUEST FROM SOURCE AND PUT IT ON DEVICE
24+ var request = _source . GetNewRequest ( ) ;
25+
26+ _buffer . Push ( request ) ;
27+
28+ var requestFromBuffer = _buffer . Pop ( ) ;
29+
30+ if ( requestFromBuffer == null ) return ;
31+
32+ _device . TakeRequest ( requestFromBuffer ) ;
33+
34+ // TODO MAKE SOME KIND OF JSON ANSWER.
35+ }
36+ }
Original file line number Diff line number Diff line change 1+ using Bll . Domain . Entities ;
2+ using Bll . Domain . Factories ;
3+ using Bll . Domain . Interfaces ;
4+ using Bll . Domain . Services ;
5+ using Buffer = Bll . Domain . Entities . Buffer ;
6+
17var builder = WebApplication . CreateBuilder ( args ) ;
28
39builder . Services . AddControllers ( ) ;
410builder . Services . AddEndpointsApiExplorer ( ) ;
511builder . Services . AddSwaggerGen ( ) ;
612
13+ #region servicesDI
14+ builder . Services . AddTransient < ISimulationService , SimulationService > ( ) ;
15+
16+ builder . Services . AddTransient < ITimeProvider , TimeProvider > ( ) ;
17+ builder . Services . AddTransient < IBuffer , Buffer > ( ) ;
18+ builder . Services . AddTransient < IBufferManager , StandardBufferManager > ( ) ;
19+ builder . Services . AddTransient < IBufferManagerFactory , BufferManagerFactory > ( ) ;
20+ builder . Services . AddTransient < IDevice , Device > ( ) ;
21+ builder . Services . AddTransient < ISource , Source > ( ) ;
22+
23+ #endregion
24+
725var app = builder . Build ( ) ;
826
927if ( app . Environment . IsDevelopment ( ) )
You can’t perform that action at this time.
0 commit comments