Add materials converting from DTOs

This commit is contained in:
Evgeny Redikultsev
2024-10-27 21:29:50 +05:00
parent b0c24126da
commit 223e69263f
71 changed files with 1398 additions and 253 deletions

View File

@@ -10,7 +10,7 @@ namespace StructureHelperLogic.Models.Analyses
public Guid Id { get; private set; }
public string Name { get; set; }
public string Tags { get; set; }
public IVersionProcessor VersionProcessor { get; private set; }
public IVersionProcessor VersionProcessor { get; set; }
public CrossSectionNdmAnalysis(Guid id, IVersionProcessor versionProcessor)
{

View File

@@ -8,7 +8,7 @@ namespace StructureHelperLogics.Models.CrossSections
{
public class CrossSection : ICrossSection
{
public ICrossSectionRepository SectionRepository { get; private set; } = new CrossSectionRepository();
public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository();
public Guid Id { get; private set; }

View File

@@ -9,6 +9,6 @@ namespace StructureHelperLogics.Models.CrossSections
{
public interface ICrossSection : ISaveable, ICloneable
{
ICrossSectionRepository SectionRepository { get; }
ICrossSectionRepository SectionRepository { get; set; }
}
}

View File

@@ -1,5 +1,6 @@
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials.Libraries;
@@ -14,9 +15,9 @@ namespace StructureHelperLogics.Models.Materials
public class FRMaterial : IFRMaterial
{
private IElasticMaterialLogic elasticMaterialLogic => new ElasticMaterialLogic();
private MaterialTypes materialType;
IUpdateStrategy<IFRMaterial> updateStrategy = new FRUpdateStrategy();
public Guid Id { get; }
public MaterialTypes MaterialType { get; }
public double Modulus{ get; set; }
public double CompressiveStrength { get; set; }
public double TensileStrength { get; set; }
@@ -28,11 +29,16 @@ namespace StructureHelperLogics.Models.Materials
public FRMaterial(MaterialTypes materialType, Guid id)
{
if (materialType != MaterialTypes.CarbonFiber ||
materialType != MaterialTypes.GlassFiber)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $": Material type {materialType} is not right");
}
Id = id;
ULSConcreteStrength = 14e6d;
SumThickness = 0.175e-3d;
this.materialType = materialType;
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultFRSafetyFactors(ProgramSetting.FRCodeType, this.materialType));
MaterialType = materialType;
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultFRSafetyFactors(ProgramSetting.FRCodeType, this.MaterialType));
}
public FRMaterial(MaterialTypes materialType) : this (materialType, Guid.NewGuid())
@@ -42,7 +48,7 @@ namespace StructureHelperLogics.Models.Materials
public object Clone()
{
var newItem = new FRMaterial(this.materialType);
var newItem = new FRMaterial(this.MaterialType);
updateStrategy.Update(newItem, this);
return newItem;
}

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -9,6 +10,7 @@ namespace StructureHelperLogics.Models.Materials
{
public interface IFRMaterial : IElasticMaterial
{
MaterialTypes MaterialType { get; }
double ULSConcreteStrength { get; set; }
double SumThickness { get; set; }
double GammaF2 { get; }

View File

@@ -1,32 +0,0 @@
using StructureHelper.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials
{
public class HeadMaterialRepository : IHeadMaterialRepository
{
public object Parent { get; private set; }
public List<IHeadMaterial> HeadMaterials { get; set; }
public HeadMaterialRepository()
{
HeadMaterials = new List<IHeadMaterial>();
}
public HeadMaterialRepository(object parent)
{
Parent = parent;
HeadMaterials = new List<IHeadMaterial>();
}
public void RegisterParent(object obj)
{
Parent = obj;
}
}
}

View File

@@ -9,6 +9,6 @@ namespace StructureHelperLogics.Models.Materials
{
public interface IHasHeadMaterials
{
List<IHeadMaterial> HeadMaterials { get; }
List<IHeadMaterial> HeadMaterials { get;}
}
}

View File

@@ -1,17 +0,0 @@
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.Materials;
using System.Windows.Media;
namespace StructureHelper.Models.Materials
{
public interface IHeadMaterial : ISaveable, ICloneable
{
string Name { get; set; }
Color Color { get; set; }
IHelperMaterial HelperMaterial { get; set; }
IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
}
}

View File

@@ -1,18 +0,0 @@
using StructureHelper.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace StructureHelperLogics.Models.Materials
{
public interface IHeadMaterialRepository
{
object Parent { get; }
List<IHeadMaterial> HeadMaterials { get; set; }
void RegisterParent(object obj);
}
}

View File

@@ -1,18 +0,0 @@
using LoaderCalculator.Data.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Materials
{
public interface IHelperMaterial : ISaveable, ICloneable
{
IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
List<IMaterialSafetyFactor> SafetyFactors { get; set; }
}
}

View File

@@ -1,18 +0,0 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Materials
{
public interface ILibMaterial : IHelperMaterial
{
ILibMaterialEntity MaterialEntity { get; set; }
IMaterialLogic MaterialLogic { get; set; }
List<IMaterialLogic> MaterialLogics { get; }
(double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm);
}
}

View File

@@ -0,0 +1,23 @@
using StructureHelper.Models.Materials;
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 HeadMaterialBaseUpdateStrategy : IUpdateStrategy<IHeadMaterial>
{
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
{
CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name;
targetObject.Color = sourceObject.Color;
}
}
}

View File

@@ -6,6 +6,7 @@ namespace StructureHelperLogics.Models.Materials
{
public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
{
private IUpdateStrategy<IHeadMaterial> updateStrategy = new HeadMaterialBaseUpdateStrategy();
private IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy;
public HeadMaterialUpdateStrategy(IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy)
@@ -19,8 +20,7 @@ namespace StructureHelperLogics.Models.Materials
CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name;
targetObject.Color = sourceObject.Color;
updateStrategy.Update(targetObject, sourceObject);
targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
helperMaterialUpdateStrategy.Update(targetObject.HelperMaterial, sourceObject.HelperMaterial);
}