Add Safety FactorConverter

This commit is contained in:
Evgeny Redikultsev
2024-10-06 17:53:49 +05:00
parent 58b6e0eb8b
commit 018a989ba6
21 changed files with 387 additions and 86 deletions

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
@@ -12,12 +13,38 @@ namespace DataAccess.DTOs.Converters
{
internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
{
private IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public HelperMaterialToDTOConvertStrategy(
IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy)
{
this.concreteConvertStrategy = concreteConvertStrategy;
}
public HelperMaterialToDTOConvertStrategy() : this (new ConcreteLibMaterialToDTOConvertStrategy())
{
}
public IHelperMaterial Convert(IHelperMaterial source)
{
Check();
if (source is IConcreteLibMaterial concreteLibMaterial)
{
concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary;
concreteConvertStrategy.TraceLogger = TraceLogger;
return concreteConvertStrategy.Convert(concreteLibMaterial);
}
if (source is IReinforcementLibMaterial reinforcementMaterial)
{
return source;
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source));
}
}
private void Check()