Add Safety FactorConverter
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
using LoaderCalculator.Data.Materials;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
using StructureHelperCommon.Models.Materials;
|
using StructureHelperCommon.Models.Materials;
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
using StructureHelperCommon.Models.Materials.Libraries;
|
||||||
using StructureHelperLogics.Models.Materials;
|
using StructureHelperLogics.Models.Materials;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -14,6 +16,8 @@ namespace DataAccess.DTOs
|
|||||||
{
|
{
|
||||||
public class ConcreteLibMaterialDTO : IConcreteLibMaterial
|
public class ConcreteLibMaterialDTO : IConcreteLibMaterial
|
||||||
{
|
{
|
||||||
|
const MaterialTypes materialType = MaterialTypes.Concrete;
|
||||||
|
|
||||||
[JsonProperty("Id")]
|
[JsonProperty("Id")]
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
[JsonProperty("RelativeHumidity")]
|
[JsonProperty("RelativeHumidity")]
|
||||||
@@ -22,19 +26,36 @@ namespace DataAccess.DTOs
|
|||||||
public double MinAge { get; set; }
|
public double MinAge { get; set; }
|
||||||
[JsonProperty("MaxAge")]
|
[JsonProperty("MaxAge")]
|
||||||
public double MaxAge { get; set; }
|
public double MaxAge { get; set; }
|
||||||
[JsonProperty("MaterialEntity")]
|
[JsonProperty("MaterialEntityId")]
|
||||||
|
public Guid MaterialEntityId
|
||||||
|
{
|
||||||
|
get => MaterialEntity.Id;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
MaterialEntity = ProgramSetting.MaterialRepository.Repository.Single(x => x.Id == value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[JsonIgnore]
|
||||||
public ILibMaterialEntity MaterialEntity { get; set; }
|
public ILibMaterialEntity MaterialEntity { get; set; }
|
||||||
[JsonProperty("SafetyFactors")]
|
[JsonProperty("SafetyFactors")]
|
||||||
public List<IMaterialSafetyFactor> SafetyFactors { get; set; }
|
public List<IMaterialSafetyFactor> SafetyFactors { get; set; } = new();
|
||||||
[JsonProperty("TensionForULS")]
|
[JsonProperty("TensionForULS")]
|
||||||
public bool TensionForULS { get; set; }
|
public bool TensionForULS { get; set; }
|
||||||
[JsonProperty("TensionForSLS")]
|
[JsonProperty("TensionForSLS")]
|
||||||
public bool TensionForSLS { get; set; }
|
public bool TensionForSLS { get; set; }
|
||||||
|
[JsonProperty("MaterialLogicId")]
|
||||||
|
public Guid MaterialLogicId
|
||||||
public IMaterialLogic MaterialLogic { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
{
|
||||||
|
get => MaterialLogic.Id;
|
||||||
public List<IMaterialLogic> MaterialLogics => throw new NotImplementedException();
|
set
|
||||||
|
{
|
||||||
|
MaterialLogic = MaterialLogics.Single(x => x.Id == value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[JsonIgnore]
|
||||||
|
public IMaterialLogic MaterialLogic { get; set; }
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<IMaterialLogic> MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList();
|
||||||
|
|
||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
|
using StructureHelperCommon.Models.Loggers;
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
using StructureHelperLogics.Models.Materials;
|
using StructureHelperLogics.Models.Materials;
|
||||||
using System;
|
using System;
|
||||||
@@ -12,13 +13,30 @@ namespace DataAccess.DTOs.Converters
|
|||||||
{
|
{
|
||||||
public class ConcreteLibMaterialToDTOConvertStrategy : IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>
|
public class ConcreteLibMaterialToDTOConvertStrategy : IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial>
|
||||||
{
|
{
|
||||||
|
private IUpdateStrategy<IConcreteLibMaterial> updateStrategy = new ConcreteLibUpdateStrategy();
|
||||||
|
private IUpdateStrategy<ILibMaterial> libMaterialUpdateStrategy = new LibMaterialDTOUpdateStrategy();
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||||
public IShiftTraceLogger TraceLogger { get; set; }
|
public IShiftTraceLogger TraceLogger { get; set; }
|
||||||
|
|
||||||
public ConcreteLibMaterialDTO Convert(IConcreteLibMaterial source)
|
public ConcreteLibMaterialDTO Convert(IConcreteLibMaterial source)
|
||||||
{
|
{
|
||||||
Check();
|
Check();
|
||||||
|
ConcreteLibMaterialDTO newItem = new()
|
||||||
|
{
|
||||||
|
Id = source.Id
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
updateStrategy.Update(newItem, source);
|
||||||
|
libMaterialUpdateStrategy.Update(newItem, source);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TraceLogger?.AddMessage(LoggerStrings.LogicType(this), TraceLogStatuses.Debug);
|
||||||
|
TraceLogger?.AddMessage(ex.Message, TraceLogStatuses.Error);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Check()
|
private void Check()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using StructureHelper.Models.Materials;
|
using StructureHelper.Models.Materials;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
using StructureHelperLogics.Models.Materials;
|
using StructureHelperLogics.Models.Materials;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -13,13 +14,18 @@ namespace DataAccess.DTOs.Converters
|
|||||||
public class HeadMaterialToDTOConvertStrategy : IConvertStrategy<HeadMaterialDTO, IHeadMaterial>
|
public class HeadMaterialToDTOConvertStrategy : IConvertStrategy<HeadMaterialDTO, IHeadMaterial>
|
||||||
{
|
{
|
||||||
private IUpdateStrategy<IHeadMaterial> updateStrategy;
|
private IUpdateStrategy<IHeadMaterial> updateStrategy;
|
||||||
|
private IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy;
|
||||||
|
|
||||||
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy)
|
public HeadMaterialToDTOConvertStrategy(IUpdateStrategy<IHeadMaterial> updateStrategy,
|
||||||
|
IConvertStrategy<IHelperMaterial, IHelperMaterial> convertStrategy)
|
||||||
{
|
{
|
||||||
this.updateStrategy = updateStrategy;
|
this.updateStrategy = updateStrategy;
|
||||||
|
this.convertStrategy = convertStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeadMaterialToDTOConvertStrategy() : this (new HeadMaterialUpdateStrategy())
|
public HeadMaterialToDTOConvertStrategy() : this (
|
||||||
|
new HeadMaterialUpdateStrategy(),
|
||||||
|
new HelperMaterialToDTOConvertStrategy())
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,8 +35,20 @@ namespace DataAccess.DTOs.Converters
|
|||||||
|
|
||||||
public HeadMaterialDTO Convert(IHeadMaterial source)
|
public HeadMaterialDTO Convert(IHeadMaterial source)
|
||||||
{
|
{
|
||||||
HeadMaterialDTO newItem = new() { Id = source.Id};
|
TraceLogger?.AddMessage($"Convert material Id={source.Id}, name is {source.Name}");
|
||||||
|
HeadMaterialDTO newItem = new()
|
||||||
|
{
|
||||||
|
Id = source.Id
|
||||||
|
};
|
||||||
updateStrategy.Update(newItem, source);
|
updateStrategy.Update(newItem, source);
|
||||||
|
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||||
|
var convertLogic = new DictionaryConvertStrategy<IHelperMaterial, IHelperMaterial>()
|
||||||
|
{
|
||||||
|
ReferenceDictionary = ReferenceDictionary,
|
||||||
|
ConvertStrategy = convertStrategy,
|
||||||
|
TraceLogger = TraceLogger
|
||||||
|
};
|
||||||
|
newItem.HelperMaterial = convertLogic.Convert(source.HelperMaterial);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Models;
|
using StructureHelperCommon.Models;
|
||||||
using StructureHelperLogics.Models.CrossSections;
|
using StructureHelperLogics.Models.CrossSections;
|
||||||
using StructureHelperLogics.Models.Materials;
|
using StructureHelperLogics.Models.Materials;
|
||||||
@@ -12,12 +13,38 @@ namespace DataAccess.DTOs.Converters
|
|||||||
{
|
{
|
||||||
internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
|
internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy<IHelperMaterial, IHelperMaterial>
|
||||||
{
|
{
|
||||||
|
private IConvertStrategy<ConcreteLibMaterialDTO, IConcreteLibMaterial> concreteConvertStrategy;
|
||||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||||
public IShiftTraceLogger TraceLogger { 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)
|
public IHelperMaterial Convert(IHelperMaterial source)
|
||||||
{
|
{
|
||||||
Check();
|
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()
|
private void Check()
|
||||||
|
|||||||
55
DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs
Normal file
55
DataAccess/DTOs/Converters/LibMaterialDTOUpdateStrategy.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models.Materials.Libraries;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using StructureHelperLogics.Models.Materials;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataAccess.DTOs.Converters
|
||||||
|
{
|
||||||
|
public class LibMaterialDTOUpdateStrategy : IUpdateStrategy<ILibMaterial>
|
||||||
|
{
|
||||||
|
private IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy;
|
||||||
|
private IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy;
|
||||||
|
|
||||||
|
public LibMaterialDTOUpdateStrategy(IUpdateStrategy<IMaterialSafetyFactor> safetyFactorUpdateStrategy,
|
||||||
|
IUpdateStrategy<IMaterialPartialFactor> partialFactorUpdateStrategy)
|
||||||
|
{
|
||||||
|
this.safetyFactorUpdateStrategy = safetyFactorUpdateStrategy;
|
||||||
|
this.partialFactorUpdateStrategy = partialFactorUpdateStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LibMaterialDTOUpdateStrategy() : this (new MaterialSafetyFactorUpdateStrategy(),
|
||||||
|
new MaterialPartialFactorUpdateStrategy())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ILibMaterial targetObject, ILibMaterial sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.IsNull(sourceObject);
|
||||||
|
CheckObject.IsNull(targetObject);
|
||||||
|
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||||
|
if (sourceObject.SafetyFactors is not null)
|
||||||
|
{
|
||||||
|
targetObject.SafetyFactors.Clear();
|
||||||
|
foreach (var safetyFactor in sourceObject.SafetyFactors)
|
||||||
|
{
|
||||||
|
MaterialSafetyFactorDTO newSafetyFactor = new() { Id = safetyFactor.Id};
|
||||||
|
safetyFactorUpdateStrategy.Update(newSafetyFactor, safetyFactor);
|
||||||
|
newSafetyFactor.PartialFactors.Clear();
|
||||||
|
foreach (var partialFactor in safetyFactor.PartialFactors)
|
||||||
|
{
|
||||||
|
MaterialPartialFactorDTO newPartialFactor = new() { Id = partialFactor.Id };
|
||||||
|
partialFactorUpdateStrategy.Update(newPartialFactor, partialFactor);
|
||||||
|
newSafetyFactor.PartialFactors.Add(newPartialFactor);
|
||||||
|
}
|
||||||
|
targetObject.SafetyFactors.Add(newSafetyFactor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Models;
|
||||||
|
using StructureHelperCommon.Models.Materials.Libraries;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataAccess.DTOs
|
||||||
|
{
|
||||||
|
public class MaterialSafetyFactorToDTOConvertStrategy : IConvertStrategy<MaterialSafetyFactorDTO, IMaterialSafetyFactor>
|
||||||
|
{
|
||||||
|
private IUpdateStrategy<IMaterialSafetyFactor> updateStrategy;
|
||||||
|
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||||
|
public IShiftTraceLogger TraceLogger { get; set; }
|
||||||
|
|
||||||
|
public MaterialSafetyFactorToDTOConvertStrategy(IUpdateStrategy<IMaterialSafetyFactor> updateStrategy)
|
||||||
|
{
|
||||||
|
this.updateStrategy = updateStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialSafetyFactorDTO Convert(IMaterialSafetyFactor source)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
DataAccess/DTOs/MaterialPartialFactorDTO.cs
Normal file
24
DataAccess/DTOs/MaterialPartialFactorDTO.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Models.Materials.Libraries;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataAccess.DTOs
|
||||||
|
{
|
||||||
|
public class MaterialPartialFactorDTO : IMaterialPartialFactor
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public double FactorValue { get; set; }
|
||||||
|
public StressStates StressState { get; set; }
|
||||||
|
public CalcTerms CalcTerm { get; set; }
|
||||||
|
public LimitStates LimitState { get; set; }
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
36
DataAccess/DTOs/MaterialSafetyFactorDTO.cs
Normal file
36
DataAccess/DTOs/MaterialSafetyFactorDTO.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Models.Materials.Libraries;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DataAccess.DTOs
|
||||||
|
{
|
||||||
|
public class MaterialSafetyFactorDTO : IMaterialSafetyFactor
|
||||||
|
{
|
||||||
|
[JsonProperty("Id")]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
[JsonProperty("Name")]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[JsonProperty("Take")]
|
||||||
|
public bool Take { get; set; }
|
||||||
|
[JsonProperty("Description")]
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
[JsonProperty("PartialFactors")]
|
||||||
|
public List<IMaterialPartialFactor> PartialFactors { get; } = new();
|
||||||
|
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetFactor(StressStates stressState, CalcTerms calcTerm, LimitStates limitStates)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ using StructureHelperCommon.Infrastructures.Exceptions;
|
|||||||
using StructureHelperCommon.Models.Analyses;
|
using StructureHelperCommon.Models.Analyses;
|
||||||
using StructureHelperCommon.Models.Calculators;
|
using StructureHelperCommon.Models.Calculators;
|
||||||
using StructureHelperCommon.Models.Forces;
|
using StructureHelperCommon.Models.Forces;
|
||||||
|
using StructureHelperCommon.Models.Materials.Libraries;
|
||||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -43,15 +44,20 @@ namespace DataAccess.DTOs
|
|||||||
{ (typeof(DateVersionDTO), "DateVersion") },
|
{ (typeof(DateVersionDTO), "DateVersion") },
|
||||||
{ (typeof(FileVersionDTO), "FileVersion") },
|
{ (typeof(FileVersionDTO), "FileVersion") },
|
||||||
{ (typeof(HeadMaterialDTO), "HeadMaterial") },
|
{ (typeof(HeadMaterialDTO), "HeadMaterial") },
|
||||||
|
{ (typeof(MaterialSafetyFactorDTO), "MaterialSafetyFactor") },
|
||||||
{ (typeof(NdmPrimitiveDTO), "NdmPrimitive") },
|
{ (typeof(NdmPrimitiveDTO), "NdmPrimitive") },
|
||||||
{ (typeof(IVisualAnalysis), "IVisualAnalysis") },
|
{ (typeof(IVisualAnalysis), "IVisualAnalysis") },
|
||||||
{ (typeof(List<ICalculator>), "ListOfICalculator") },
|
{ (typeof(List<ICalculator>), "ListOfICalculator") },
|
||||||
{ (typeof(List<IDateVersion>), "ListOfIDateVersion") },
|
{ (typeof(List<IDateVersion>), "ListOfIDateVersion") },
|
||||||
{ (typeof(List<IForceAction>), "ListOfIForceAction") },
|
{ (typeof(List<IForceAction>), "ListOfIForceAction") },
|
||||||
{ (typeof(List<IHeadMaterial>), "ListOfIHeadMaterial") },
|
{ (typeof(List<IHeadMaterial>), "ListOfIHeadMaterial") },
|
||||||
|
{ (typeof(List<IMaterialSafetyFactor>), "ListOfMaterialSafetyFactor") },
|
||||||
|
{ (typeof(List<IMaterialPartialFactor>), "ListOfMaterialPartialFactor") },
|
||||||
{ (typeof(List<INdmPrimitive>), "ListOfINdmPrimitive") },
|
{ (typeof(List<INdmPrimitive>), "ListOfINdmPrimitive") },
|
||||||
|
{ (typeof(List<IPartialFactor>), "ListOfPartialFactor") },
|
||||||
{ (typeof(List<IVisualAnalysis>), "ListOfIVisualAnalysis") },
|
{ (typeof(List<IVisualAnalysis>), "ListOfIVisualAnalysis") },
|
||||||
{ (typeof(ProjectDTO), "Project") },
|
{ (typeof(ProjectDTO), "Project") },
|
||||||
|
{ (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") },
|
||||||
{ (typeof(VersionProcessorDTO), "VersionProcessor") },
|
{ (typeof(VersionProcessorDTO), "VersionProcessor") },
|
||||||
{ (typeof(VisualAnalysisDTO), "VisualAnalysis") },
|
{ (typeof(VisualAnalysisDTO), "VisualAnalysis") },
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using LoaderCalculator.Data.Materials.MaterialBuilders;
|
using LoaderCalculator.Data.Materials.MaterialBuilders;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Materials
|
namespace StructureHelperCommon.Models.Materials
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ namespace StructureHelperCommon.Models.Materials
|
|||||||
private ConcreteLogicOptions options;
|
private ConcreteLogicOptions options;
|
||||||
|
|
||||||
|
|
||||||
|
public Guid Id { get; private set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public IMaterialLogicOptions Options
|
public IMaterialLogicOptions Options
|
||||||
{
|
{
|
||||||
@@ -29,6 +31,11 @@ namespace StructureHelperCommon.Models.Materials
|
|||||||
public MaterialTypes MaterialType { get; set; }
|
public MaterialTypes MaterialType { get; set; }
|
||||||
public DiagramType DiagramType { get; set; }
|
public DiagramType DiagramType { get; set; }
|
||||||
|
|
||||||
|
public ConcreteCurveLogic(Guid id)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public IMaterial GetLoaderMaterial()
|
public IMaterial GetLoaderMaterial()
|
||||||
{
|
{
|
||||||
GetLoaderOptions();
|
GetLoaderOptions();
|
||||||
|
|||||||
@@ -15,9 +15,24 @@ namespace StructureHelperCommon.Models.Materials
|
|||||||
{
|
{
|
||||||
var items = new List<IMaterialLogic>()
|
var items = new List<IMaterialLogic>()
|
||||||
{
|
{
|
||||||
new ReinforcementByBuilderLogic() { MaterialType = MaterialTypes.Reinforcement, Name="Bilinear", DiagramType = DiagramType.Bilinear},
|
new ReinforcementByBuilderLogic(Guid.Parse("54c4fe40-8f82-4995-8930-81e65e97edb9"))
|
||||||
new ReinforcementByBuilderLogic() { MaterialType = MaterialTypes.Reinforcement, Name="Triplelinear", DiagramType = DiagramType.TripleLinear},
|
{
|
||||||
new ConcreteCurveLogic() { MaterialType = MaterialTypes.Concrete, Name = "Curve", DiagramType = DiagramType.Curve},
|
MaterialType = MaterialTypes.Reinforcement,
|
||||||
|
Name="Bilinear",
|
||||||
|
DiagramType = DiagramType.Bilinear
|
||||||
|
},
|
||||||
|
new ReinforcementByBuilderLogic(Guid.Parse("c658b71d-13b1-458c-a1b0-c93d1324acad"))
|
||||||
|
{
|
||||||
|
MaterialType = MaterialTypes.Reinforcement,
|
||||||
|
Name="Triplelinear",
|
||||||
|
DiagramType = DiagramType.TripleLinear
|
||||||
|
},
|
||||||
|
new ConcreteCurveLogic(Guid.Parse("b97e8168-76a1-4e24-ae98-9aa38edd1e9a"))
|
||||||
|
{
|
||||||
|
MaterialType = MaterialTypes.Concrete,
|
||||||
|
Name = "Curve",
|
||||||
|
DiagramType = DiagramType.Curve
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
using LoaderCalculator.Data.Materials;
|
||||||
using LoaderCalculator.Data.Materials.MaterialBuilders;
|
using LoaderCalculator.Data.Materials.MaterialBuilders;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -9,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperCommon.Models.Materials
|
namespace StructureHelperCommon.Models.Materials
|
||||||
{
|
{
|
||||||
public interface IMaterialLogic
|
public interface IMaterialLogic : ISaveable
|
||||||
{
|
{
|
||||||
string Name { get; set; }
|
string Name { get; set; }
|
||||||
IMaterialLogicOptions Options { get; set; }
|
IMaterialLogicOptions Options { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -7,10 +8,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperCommon.Models.Materials.Libraries
|
namespace StructureHelperCommon.Models.Materials.Libraries
|
||||||
{
|
{
|
||||||
internal class MaterialPartialFactorUpdateStrategy : IUpdateStrategy<IMaterialPartialFactor>
|
public class MaterialPartialFactorUpdateStrategy : IUpdateStrategy<IMaterialPartialFactor>
|
||||||
{
|
{
|
||||||
public void Update(IMaterialPartialFactor targetObject, IMaterialPartialFactor sourceObject)
|
public void Update(IMaterialPartialFactor targetObject, IMaterialPartialFactor sourceObject)
|
||||||
{
|
{
|
||||||
|
CheckObject.IsNull(sourceObject);
|
||||||
|
CheckObject.IsNull(targetObject);
|
||||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||||
targetObject.LimitState = sourceObject.LimitState;
|
targetObject.LimitState = sourceObject.LimitState;
|
||||||
targetObject.StressState = sourceObject.StressState;
|
targetObject.StressState = sourceObject.StressState;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -7,10 +8,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StructureHelperCommon.Models.Materials.Libraries
|
namespace StructureHelperCommon.Models.Materials.Libraries
|
||||||
{
|
{
|
||||||
internal class MaterialSafetyFactorUpdateStrategy : IUpdateStrategy<IMaterialSafetyFactor>
|
public class MaterialSafetyFactorUpdateStrategy : IUpdateStrategy<IMaterialSafetyFactor>
|
||||||
{
|
{
|
||||||
public void Update(IMaterialSafetyFactor targetObject, IMaterialSafetyFactor sourceObject)
|
public void Update(IMaterialSafetyFactor targetObject, IMaterialSafetyFactor sourceObject)
|
||||||
{
|
{
|
||||||
|
CheckObject.IsNull(sourceObject);
|
||||||
|
CheckObject.IsNull(targetObject);
|
||||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||||
targetObject.Name = sourceObject.Name;
|
targetObject.Name = sourceObject.Name;
|
||||||
targetObject.Take = sourceObject.Take;
|
targetObject.Take = sourceObject.Take;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Materials.Libraries
|
namespace StructureHelperCommon.Models.Materials.Libraries
|
||||||
@@ -7,10 +8,12 @@ namespace StructureHelperCommon.Models.Materials.Libraries
|
|||||||
public class MaterialPartialFactor : IMaterialPartialFactor
|
public class MaterialPartialFactor : IMaterialPartialFactor
|
||||||
{
|
{
|
||||||
private double factorValue;
|
private double factorValue;
|
||||||
|
private IUpdateStrategy<IMaterialPartialFactor> updateStrategy = new MaterialPartialFactorUpdateStrategy();
|
||||||
|
|
||||||
public Guid Id { get; }
|
public Guid Id { get; }
|
||||||
public StressStates StressState { get; set; }
|
public StressStates StressState { get; set; } = StressStates.Compression;
|
||||||
public CalcTerms CalcTerm { get; set; }
|
public CalcTerms CalcTerm { get; set; } = CalcTerms.LongTerm;
|
||||||
public LimitStates LimitState { get; set; }
|
public LimitStates LimitState { get; set; } = LimitStates.ULS;
|
||||||
public double FactorValue
|
public double FactorValue
|
||||||
{
|
{
|
||||||
get => factorValue;
|
get => factorValue;
|
||||||
@@ -28,9 +31,6 @@ namespace StructureHelperCommon.Models.Materials.Libraries
|
|||||||
public MaterialPartialFactor(Guid id)
|
public MaterialPartialFactor(Guid id)
|
||||||
{
|
{
|
||||||
Id = id;
|
Id = id;
|
||||||
StressState = StressStates.Compression;
|
|
||||||
LimitState = LimitStates.ULS;
|
|
||||||
CalcTerm = CalcTerms.LongTerm;
|
|
||||||
FactorValue = 1d;
|
FactorValue = 1d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,6 @@ namespace StructureHelperCommon.Models.Materials.Libraries
|
|||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var newItem = new MaterialPartialFactor();
|
var newItem = new MaterialPartialFactor();
|
||||||
var updateStrategy = new MaterialPartialFactorUpdateStrategy();
|
|
||||||
updateStrategy.Update(newItem, this);
|
updateStrategy.Update(newItem, this);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using LoaderCalculator.Data.Materials.MaterialBuilders;
|
|||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
using StructureHelperCommon.Services;
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Materials
|
namespace StructureHelperCommon.Models.Materials
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ namespace StructureHelperCommon.Models.Materials
|
|||||||
private ReinforcementOptions materialOptions;
|
private ReinforcementOptions materialOptions;
|
||||||
private IMaterialOptionLogic optionLogic;
|
private IMaterialOptionLogic optionLogic;
|
||||||
|
|
||||||
|
public Guid Id { get; private set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public DiagramType DiagramType { get; set; }
|
public DiagramType DiagramType { get; set; }
|
||||||
public IMaterialLogicOptions Options
|
public IMaterialLogicOptions Options
|
||||||
@@ -26,6 +28,10 @@ namespace StructureHelperCommon.Models.Materials
|
|||||||
|
|
||||||
public MaterialTypes MaterialType { get; set; }
|
public MaterialTypes MaterialType { get; set; }
|
||||||
|
|
||||||
|
public ReinforcementByBuilderLogic(Guid id)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
}
|
||||||
public IMaterial GetLoaderMaterial()
|
public IMaterial GetLoaderMaterial()
|
||||||
{
|
{
|
||||||
GetLoaderOptions();
|
GetLoaderOptions();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using LoaderCalculator.Data.Materials;
|
using LoaderCalculator.Data.Materials;
|
||||||
using StructureHelperCommon.Infrastructures.Enums;
|
using StructureHelperCommon.Infrastructures.Enums;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Infrastructures.Settings;
|
using StructureHelperCommon.Infrastructures.Settings;
|
||||||
using StructureHelperCommon.Models.Materials;
|
using StructureHelperCommon.Models.Materials;
|
||||||
using StructureHelperCommon.Models.Materials.Libraries;
|
using StructureHelperCommon.Models.Materials.Libraries;
|
||||||
@@ -18,6 +19,7 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
private IMaterialOptionLogic optionLogic;
|
private IMaterialOptionLogic optionLogic;
|
||||||
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors);
|
private IFactorLogic factorLogic => new FactorLogic(SafetyFactors);
|
||||||
private LMLogic.ITrueStrengthLogic strengthLogic;
|
private LMLogic.ITrueStrengthLogic strengthLogic;
|
||||||
|
private IUpdateStrategy<IConcreteLibMaterial> updateStrategy = new ConcreteLibUpdateStrategy();
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public Guid Id { get; }
|
public Guid Id { get; }
|
||||||
@@ -64,7 +66,6 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var newItem = new ConcreteLibMaterial();
|
var newItem = new ConcreteLibMaterial();
|
||||||
var updateStrategy = new ConcreteLibUpdateStrategy();
|
|
||||||
updateStrategy.Update(newItem, this);
|
updateStrategy.Update(newItem, this);
|
||||||
return newItem;
|
return newItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,15 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
}
|
}
|
||||||
public void Update(IConcreteLibMaterial targetObject, IConcreteLibMaterial sourceObject)
|
public void Update(IConcreteLibMaterial targetObject, IConcreteLibMaterial sourceObject)
|
||||||
{
|
{
|
||||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
CheckObject.IsNull(sourceObject);
|
||||||
|
CheckObject.IsNull(targetObject);
|
||||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||||
libUpdateStrategy.Update(targetObject, sourceObject);
|
libUpdateStrategy.Update(targetObject, sourceObject);
|
||||||
targetObject.TensionForULS = sourceObject.TensionForULS;
|
targetObject.TensionForULS = sourceObject.TensionForULS;
|
||||||
targetObject.TensionForSLS = sourceObject.TensionForSLS;
|
targetObject.TensionForSLS = sourceObject.TensionForSLS;
|
||||||
targetObject.RelativeHumidity = sourceObject.RelativeHumidity;
|
targetObject.RelativeHumidity = sourceObject.RelativeHumidity;
|
||||||
|
targetObject.MinAge = sourceObject.MinAge;
|
||||||
|
targetObject.MaxAge = sourceObject.MaxAge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using StructureHelper.Models.Materials;
|
using StructureHelper.Models.Materials;
|
||||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Services;
|
using StructureHelperCommon.Services;
|
||||||
|
|
||||||
@@ -7,27 +6,13 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
{
|
{
|
||||||
public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
||||||
{
|
{
|
||||||
private IUpdateStrategy<IElasticMaterial> elasticStrategy;
|
private IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy;
|
||||||
private IUpdateStrategy<IFRMaterial> frStrategy;
|
|
||||||
private IUpdateStrategy<IConcreteLibMaterial> concreteStrategy;
|
public HeadMaterialUpdateStrategy(IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy)
|
||||||
private IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy;
|
|
||||||
public HeadMaterialUpdateStrategy(IUpdateStrategy<IElasticMaterial> elasticStrategy,
|
|
||||||
IUpdateStrategy<IFRMaterial> frStrategy,
|
|
||||||
IUpdateStrategy<IConcreteLibMaterial> concreteStrategy,
|
|
||||||
IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this.elasticStrategy = elasticStrategy;
|
this.helperMaterialUpdateStrategy = helperMaterialUpdateStrategy;
|
||||||
this.frStrategy = frStrategy;
|
|
||||||
this.concreteStrategy = concreteStrategy;
|
|
||||||
this.reinforcementStrategy= reinforcementStrategy;
|
|
||||||
}
|
}
|
||||||
public HeadMaterialUpdateStrategy() : this(
|
public HeadMaterialUpdateStrategy() : this(new HelperMaterialUpdateStrategy()) { }
|
||||||
new ElasticUpdateStrategy(),
|
|
||||||
new FRUpdateStrategy(),
|
|
||||||
new ConcreteLibUpdateStrategy(),
|
|
||||||
new ReinforcementLibUpdateStrategy()
|
|
||||||
) { }
|
|
||||||
|
|
||||||
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
|
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
|
||||||
{
|
{
|
||||||
@@ -37,44 +22,9 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
targetObject.Name = sourceObject.Name;
|
targetObject.Name = sourceObject.Name;
|
||||||
targetObject.Color = sourceObject.Color;
|
targetObject.Color = sourceObject.Color;
|
||||||
targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
|
targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
|
||||||
UpdateHelperMaterial(targetObject.HelperMaterial, sourceObject.HelperMaterial);
|
helperMaterialUpdateStrategy.Update(targetObject.HelperMaterial, sourceObject.HelperMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateHelperMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
|
||||||
{
|
|
||||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
|
||||||
if (sourceObject is ILibMaterial)
|
|
||||||
{
|
|
||||||
UpdateLibMaterial(targetObject, sourceObject);
|
|
||||||
}
|
|
||||||
else if (sourceObject is IElasticMaterial)
|
|
||||||
{
|
|
||||||
elasticStrategy.Update(targetObject as IElasticMaterial, sourceObject as IElasticMaterial);
|
|
||||||
}
|
|
||||||
else if (sourceObject is IFRMaterial)
|
|
||||||
{
|
|
||||||
frStrategy.Update(targetObject as IFRMaterial, sourceObject as IFRMaterial);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(IHelperMaterial), sourceObject.GetType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateLibMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
|
||||||
{
|
|
||||||
if (sourceObject is IConcreteLibMaterial)
|
|
||||||
{
|
|
||||||
concreteStrategy.Update(targetObject as IConcreteLibMaterial, sourceObject as IConcreteLibMaterial);
|
|
||||||
}
|
|
||||||
else if (sourceObject is IReinforcementLibMaterial)
|
|
||||||
{
|
|
||||||
reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, sourceObject as IReinforcementLibMaterial);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(ILibMaterial), sourceObject.GetType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||||
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
|
using StructureHelperCommon.Services;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace StructureHelperLogics.Models.Materials
|
||||||
|
{
|
||||||
|
public class HelperMaterialUpdateStrategy : IUpdateStrategy<IHelperMaterial>
|
||||||
|
{
|
||||||
|
private IUpdateStrategy<IElasticMaterial> elasticStrategy;
|
||||||
|
private IUpdateStrategy<IFRMaterial> frStrategy;
|
||||||
|
private IUpdateStrategy<IConcreteLibMaterial> concreteStrategy;
|
||||||
|
private IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy;
|
||||||
|
public HelperMaterialUpdateStrategy(IUpdateStrategy<IElasticMaterial> elasticStrategy,
|
||||||
|
IUpdateStrategy<IFRMaterial> frStrategy,
|
||||||
|
IUpdateStrategy<IConcreteLibMaterial> concreteStrategy,
|
||||||
|
IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this.elasticStrategy = elasticStrategy;
|
||||||
|
this.frStrategy = frStrategy;
|
||||||
|
this.concreteStrategy = concreteStrategy;
|
||||||
|
this.reinforcementStrategy = reinforcementStrategy;
|
||||||
|
}
|
||||||
|
public HelperMaterialUpdateStrategy() : this(
|
||||||
|
new ElasticUpdateStrategy(),
|
||||||
|
new FRUpdateStrategy(),
|
||||||
|
new ConcreteLibUpdateStrategy(),
|
||||||
|
new ReinforcementLibUpdateStrategy()
|
||||||
|
)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||||
|
{
|
||||||
|
CheckObject.IsNull(sourceObject);
|
||||||
|
CheckObject.IsNull(targetObject);
|
||||||
|
if (sourceObject is ILibMaterial)
|
||||||
|
{
|
||||||
|
UpdateLibMaterial(targetObject, sourceObject);
|
||||||
|
}
|
||||||
|
else if (sourceObject is IElasticMaterial)
|
||||||
|
{
|
||||||
|
elasticStrategy.Update(targetObject as IElasticMaterial, sourceObject as IElasticMaterial);
|
||||||
|
}
|
||||||
|
else if (sourceObject is IFRMaterial)
|
||||||
|
{
|
||||||
|
frStrategy.Update(targetObject as IFRMaterial, sourceObject as IFRMaterial);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(IHelperMaterial), sourceObject.GetType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLibMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||||
|
{
|
||||||
|
if (sourceObject is IConcreteLibMaterial)
|
||||||
|
{
|
||||||
|
concreteStrategy.Update(targetObject as IConcreteLibMaterial, sourceObject as IConcreteLibMaterial);
|
||||||
|
}
|
||||||
|
else if (sourceObject is IReinforcementLibMaterial)
|
||||||
|
{
|
||||||
|
reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, sourceObject as IReinforcementLibMaterial);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(ILibMaterial), sourceObject.GetType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,11 +13,16 @@ namespace StructureHelperLogics.Models.Materials
|
|||||||
{
|
{
|
||||||
public void Update(ILibMaterial targetObject, ILibMaterial sourceObject)
|
public void Update(ILibMaterial targetObject, ILibMaterial sourceObject)
|
||||||
{
|
{
|
||||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
CheckObject.IsNull(sourceObject);
|
||||||
|
CheckObject.IsNull(targetObject);
|
||||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||||
targetObject.MaterialEntity = sourceObject.MaterialEntity;
|
targetObject.MaterialEntity = sourceObject.MaterialEntity;
|
||||||
if (targetObject.SafetyFactors is not null & sourceObject.SafetyFactors is not null)
|
if (sourceObject.SafetyFactors is not null)
|
||||||
{
|
{
|
||||||
|
if (targetObject.SafetyFactors is null)
|
||||||
|
{
|
||||||
|
targetObject.SafetyFactors = new();
|
||||||
|
}
|
||||||
targetObject.SafetyFactors.Clear();
|
targetObject.SafetyFactors.Clear();
|
||||||
foreach (var item in sourceObject.SafetyFactors)
|
foreach (var item in sourceObject.SafetyFactors)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user