Skip to content

Commit a73ca1e

Browse files
authored
Merge pull request #14 from NiceOneFox/T10_AutoMapper_Configuration_For_Results
Close Add Autommaper config. modify buffernanager factory
2 parents a27336e + dd44174 commit a73ca1e

File tree

8 files changed

+30
-26
lines changed

8 files changed

+30
-26
lines changed

backend/ServiceSimulation/Api/Configuration/ApiMapperConfigurator.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,18 @@ public ApiMapperConfigurator(IMapperConfigurationExpression expression)
2020
private void MappingApiResults(IMapperConfigurationExpression expression)
2121
{
2222
expression.CreateMap<(FinalResults, IResults), ApiResults>()
23-
.ForMember(dst => dst.AverageProbabilityOfMaintenance,
24-
opt => opt.MapFrom(src => src.Item1.AverageProbabilityOfMaintenance));
25-
//TODO CONTINUE MAP MEMBERS
23+
.ForMember(dst => dst.AverageProbabilityOfMaintenance,
24+
opt => opt.MapFrom(src => src.Item1.AverageProbabilityOfMaintenance))
25+
.ForMember(dst => dst.ProbabilityOfFailure,
26+
opt => opt.MapFrom(src => src.Item1.ProbabilityOfFailure))
27+
.ForMember(dst => dst.BandwidthOfSystem,
28+
opt => opt.MapFrom(src => src.Item1.BandwidthOfSystem))
29+
.ForMember(dst => dst.AmountOfGeneratedRequests,
30+
31+
opt => opt.MapFrom(src => src.Item2.AmountOfGeneratedRequests))
32+
.ForMember(dst => dst.AmountOfServedRequest,
33+
opt => opt.MapFrom(src => src.Item2.AmountOfServedRequest))
34+
.ForMember(dst => dst.ModelingTime,
35+
opt => opt.MapFrom(src => src.Item2.ModelingTime));
2636
}
2737
}

backend/ServiceSimulation/Api/Controllers/Simulation.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public class Simulation : Controller
1616
private readonly IResultManager _resultManager;
1717
private readonly IMapper _mapper;
1818
public Simulation(ISimulationService simulationService,
19-
ITimeProvider time, IResults results,
20-
IResultManager resultManager,
19+
ITimeProvider time,
20+
IResults results,
21+
IResultManager resultManager,
2122
IMapper mapper)
2223
{
2324
_simulationService = simulationService;
@@ -32,7 +33,8 @@ public IActionResult Start(InputParameters parameters)
3233
{
3334
_simulationService.StartSimulation(parameters);
3435
var endResultsOfModeling = _resultManager.CalculateResultsOfModeling();
35-
var apiResults = _mapper.Map<ApiResults>((endResultsOfModeling, _results)); // TODO OTHER PARAMS>?
36-
return Ok(apiResults); // TODO AUTOMAPPER CONFIGURATION!
36+
var apiResults = _mapper.Map<ApiResults>((endResultsOfModeling, _results));
37+
38+
return Ok(apiResults);
3739
}
3840
}

backend/ServiceSimulation/Bll.Domain/Entities/BufferManagerFactory.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,12 @@ public BufferManagerFactory(IServiceProvider serviceProvider)
1515
_serviceProvider = serviceProvider;
1616
}
1717

18-
public IBufferManager CreateBufferManager(SimulationType simulationType) // TODO PASS MORE PARAMETERS. SIZE BUFFER
18+
public IBufferManager CreateBufferManager(SimulationType simulationType, int capacity)
1919
{
20-
// var a = ActivatorUtilities.CreateInstance<IBufferManager>(_serviceProvider,
21-
// new StandardBufferManager(_serviceProvider.GetRequiredService<IResults>(),
22-
// _serviceProvider.GetRequiredService<ITimeProvider>(), 5));
23-
2420
return simulationType switch
2521
{
26-
0 => new StandardBufferManager(_serviceProvider.GetRequiredService<IResults>(), _serviceProvider.GetRequiredService<ITimeProvider>(), 5),
27-
//0 => (IBufferManager)_serviceProvider.GetRequiredService(typeof(StandardBufferManager)),
28-
//0 => Activator.CreateInstance<IBufferManager>(nameof(StandardBufferManager), 5),// (IBufferManager)_serviceProvider.GetService(typeof(StandardBufferManager)),
29-
// 0 => ActivatorUtilities.CreateInstance<IBufferManager>(_serviceProvider,
30-
// new StandardBufferManager(_serviceProvider.GetRequiredService<IResults>(), _serviceProvider.GetRequiredService<ITimeProvider>())),
22+
0 => new StandardBufferManager(_serviceProvider.GetRequiredService<IResults>(),
23+
_serviceProvider.GetRequiredService<ITimeProvider>(), capacity),
3124
_ => throw new NotImplementedException()
3225
};
3326
}

backend/ServiceSimulation/Bll.Domain/Entities/InputParameters.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ public class InputParameters
1010
public int AmountOfRequests { get; set; } = 40;
1111
public double ModelingTime { get; set; } = double.MaxValue;
1212
public SimulationType SimulationType { get; set; } = SimulationType.Standard;
13-
1413
public double Lambda { get; set; } = 3;
1514
}

backend/ServiceSimulation/Bll.Domain/Entities/SourceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ public Request GetNewRequest(Source source)
2929

3030
return generatedRequest;
3131
}
32-
}
32+
} // TODO Add Method Take NewRequest And GetTimeOfNextRequest ?

backend/ServiceSimulation/Bll.Domain/Factories/IBufferManagerFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace Bll.Domain.Factories;
55

66
public interface IBufferManagerFactory
77
{
8-
IBufferManager CreateBufferManager(SimulationType simulationType);
8+
IBufferManager CreateBufferManager(SimulationType simulationType, int capacity);
99
}

backend/ServiceSimulation/Bll.Domain/Services/SimulationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void StartSimulation(InputParameters parameters)
5454
});
5555
}
5656

57-
var bufferManager = _bufferManagerFactory.CreateBufferManager(parameters.SimulationType);
57+
var bufferManager = _bufferManagerFactory.CreateBufferManager(parameters.SimulationType, parameters.BufferSize);
5858

5959
foreach (var source in sources) // Generate first requests that generated by sources.
6060
{

backend/ServiceSimulation/ServiceSimulation.sln

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VisualStudioVersion = 17.1.32210.238
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bll.Domain", "Bll.Domain\Bll.Domain.csproj", "{A2F40071-9955-4AB9-9C6E-6BB2B34BC580}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "Api\Api.csproj", "{22B0B8F3-C889-42A4-AE31-C858C99EDEFF}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "Api\Api.csproj", "{454394BA-843E-47C5-A8A1-358D5629EEFC}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -17,10 +17,10 @@ Global
1717
{A2F40071-9955-4AB9-9C6E-6BB2B34BC580}.Debug|Any CPU.Build.0 = Debug|Any CPU
1818
{A2F40071-9955-4AB9-9C6E-6BB2B34BC580}.Release|Any CPU.ActiveCfg = Release|Any CPU
1919
{A2F40071-9955-4AB9-9C6E-6BB2B34BC580}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{22B0B8F3-C889-42A4-AE31-C858C99EDEFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{22B0B8F3-C889-42A4-AE31-C858C99EDEFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{22B0B8F3-C889-42A4-AE31-C858C99EDEFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{22B0B8F3-C889-42A4-AE31-C858C99EDEFF}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{454394BA-843E-47C5-A8A1-358D5629EEFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{454394BA-843E-47C5-A8A1-358D5629EEFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{454394BA-843E-47C5-A8A1-358D5629EEFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{454394BA-843E-47C5-A8A1-358D5629EEFC}.Release|Any CPU.Build.0 = Release|Any CPU
2424
EndGlobalSection
2525
GlobalSection(SolutionProperties) = preSolution
2626
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)