Material Update Strategy was added

This commit is contained in:
Evgeny Redikultsev
2023-07-02 22:03:30 +05:00
parent 2595d7e733
commit 03b882f54d
74 changed files with 456 additions and 184 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using StructureHelperCommon.Infrastructures.Enums;
@@ -6,23 +7,32 @@ namespace StructureHelperCommon.Models.Materials.Libraries
{
public class MaterialSafetyFactor : IMaterialSafetyFactor
{
public Guid Id { get; }
public string Name {get; set; }
public bool Take { get; set; }
public string Description { get; set; }
public List<IMaterialPartialFactor> PartialFactors { get; }
public MaterialSafetyFactor()
public MaterialSafetyFactor(Guid id)
{
Id = id;
Take = true;
Name = "New factor";
Description = "Material safety factor for ...";
PartialFactors = new List<IMaterialPartialFactor>();
}
public MaterialSafetyFactor() : this (Guid.NewGuid())
{ }
public double GetFactor(StressStates stressState, CalcTerms calcTerm, LimitStates limitStates)
{
double result = 1d;
var coefficients = PartialFactors.Where(x => (x.StressState == stressState & x.CalcTerm == calcTerm & x.LimitState == limitStates));
var coefficients = PartialFactors
.Where(x => x.StressState == stressState
& x.CalcTerm == calcTerm
& x.LimitState == limitStates);
foreach (var item in coefficients) { result *= item.FactorValue;}
return result;
}
@@ -30,13 +40,8 @@ namespace StructureHelperCommon.Models.Materials.Libraries
public object Clone()
{
var newItem = new MaterialSafetyFactor();
newItem.Take = Take;
newItem.Name = Name;
newItem.Description = Description;
foreach (var item in PartialFactors)
{
newItem.PartialFactors.Add(item.Clone() as IMaterialPartialFactor);
}
var updateSrategy = new MaterialSafetyFactorUpdateStrategy();
updateSrategy.Update(newItem, this);
return newItem;
}
}