Material Update Strategy was added
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user