Material Update Strategy was added
This commit is contained in:
@@ -32,7 +32,10 @@ namespace StructureHelperLogics.Models.Materials
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new ConcreteLibMaterial() { MaterialEntity = MaterialEntity, TensionForULS = TensionForULS, TensionForSLS = TensionForSLS };
|
||||
var newItem = new ConcreteLibMaterial();
|
||||
var updateStrategy = new ConcreteLibUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public LM.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
||||
|
||||
@@ -31,7 +31,10 @@ namespace StructureHelperLogics.Models.Materials
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new ElasticMaterial() { Modulus = Modulus, CompressiveStrength = CompressiveStrength, TensileStrength = TensileStrength };
|
||||
var newItem = new ElasticMaterial();
|
||||
var updateStrategy = new ElasticUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,14 +48,9 @@ namespace StructureHelperLogics.Models.Materials
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var newItem = new FRMaterial(materialType)
|
||||
{
|
||||
Modulus = Modulus,
|
||||
CompressiveStrength = CompressiveStrength,
|
||||
TensileStrength = TensileStrength,
|
||||
ULSConcreteStrength = ULSConcreteStrength,
|
||||
SumThickness = SumThickness,
|
||||
};
|
||||
var newItem = new FRMaterial(this.materialType);
|
||||
var updateStrategy = new FRUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Codes;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -9,7 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
{
|
||||
public static class PartialCoefficientFactory
|
||||
{
|
||||
public static List<IMaterialSafetyFactor> GetDefaultConcreteSafetyFactors(CodeTypes codeType)
|
||||
|
||||
@@ -50,13 +50,11 @@ namespace StructureHelper.Models.Materials
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
IHeadMaterial material = new HeadMaterial
|
||||
{
|
||||
Name = Name,
|
||||
Color = Color,
|
||||
HelperMaterial = HelperMaterial.Clone() as IHelperMaterial
|
||||
};
|
||||
return material;
|
||||
var newItem = new HeadMaterial();
|
||||
newItem.HelperMaterial = this.HelperMaterial.Clone() as IHelperMaterial;
|
||||
var updateStrategy = new MaterialUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace StructureHelper.Models.Materials
|
||||
string Name { get; set; }
|
||||
Color Color { get; set; }
|
||||
IHelperMaterial HelperMaterial { get; set; }
|
||||
//MaterialDefinitionBase Material { get; set; }
|
||||
IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System.Collections.Generic;
|
||||
using LCM = LoaderCalculator.Data.Materials;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class ConcreteLibUpdateStrategy : IUpdateStrategy<IConcreteLibMaterial>
|
||||
{
|
||||
LibMaterialUpdateStrategy libUpdateStrategy = new LibMaterialUpdateStrategy();
|
||||
public void Update(IConcreteLibMaterial targetObject, IConcreteLibMaterial sourceObject)
|
||||
{
|
||||
libUpdateStrategy.Update(targetObject, sourceObject);
|
||||
targetObject.TensionForULS = sourceObject.TensionForULS;
|
||||
targetObject.TensionForSLS = sourceObject.TensionForSLS;
|
||||
targetObject.Humidity = sourceObject.Humidity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using LCMB = LoaderCalculator.Data.Materials.MaterialBuilders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class ElasticUpdateStrategy : IUpdateStrategy<IElasticMaterial>
|
||||
{
|
||||
public void Update(IElasticMaterial targetObject, IElasticMaterial sourceObject)
|
||||
{
|
||||
targetObject.Modulus = sourceObject.Modulus;
|
||||
targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
|
||||
targetObject.TensileStrength = sourceObject.TensileStrength;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class FRUpdateStrategy : IUpdateStrategy<IFRMaterial>
|
||||
{
|
||||
public void Update(IFRMaterial targetObject, IFRMaterial sourceObject)
|
||||
{
|
||||
targetObject.Modulus = sourceObject.Modulus;
|
||||
targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
|
||||
targetObject.TensileStrength = targetObject.TensileStrength;
|
||||
targetObject.ULSConcreteStrength = targetObject.ULSConcreteStrength;
|
||||
targetObject.SumThickness = targetObject.SumThickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class LibMaterialUpdateStrategy : IUpdateStrategy<ILibMaterial>
|
||||
{
|
||||
public void Update(ILibMaterial targetObject, ILibMaterial sourceObject)
|
||||
{
|
||||
targetObject.MaterialEntity = sourceObject.MaterialEntity;
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var item in sourceObject.SafetyFactors)
|
||||
{
|
||||
targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class MaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
|
||||
{
|
||||
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
|
||||
{
|
||||
targetObject.Name = sourceObject.Name;
|
||||
targetObject.Color = sourceObject.Color;
|
||||
targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
|
||||
UpdateHelperMaterial(targetObject.HelperMaterial, sourceObject.HelperMaterial);
|
||||
}
|
||||
|
||||
private static void UpdateHelperMaterial(IHelperMaterial target, IHelperMaterial source)
|
||||
{
|
||||
Check(target, source);
|
||||
UpdateMaterial(target, source);
|
||||
}
|
||||
private static void Check(IHelperMaterial target, IHelperMaterial source)
|
||||
{
|
||||
if (target.GetType() != source.GetType())
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"target type is {target.GetType()}, \n is no coinside with source type {source.GetType()}");
|
||||
}
|
||||
}
|
||||
private static void UpdateMaterial(IHelperMaterial target, IHelperMaterial source)
|
||||
{
|
||||
if (source is ILibMaterial)
|
||||
{
|
||||
UpdateLibMaterial(target, source);
|
||||
}
|
||||
else if (source is IElasticMaterial)
|
||||
{
|
||||
UpdateElastic(target, source);
|
||||
}
|
||||
else if (source is IFRMaterial)
|
||||
{
|
||||
UpdateFR(target, source);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"\n Expected: {typeof(IHelperMaterial)},\n But was: {source.GetType()}");
|
||||
}
|
||||
}
|
||||
private static void UpdateFR(IHelperMaterial target, IHelperMaterial source)
|
||||
{
|
||||
var targetMaterial = target as IFRMaterial;
|
||||
var sourceMaterial = source as IFRMaterial;
|
||||
var logic = new FRUpdateStrategy();
|
||||
logic.Update(targetMaterial, sourceMaterial);
|
||||
}
|
||||
private static void UpdateElastic(IHelperMaterial target, IHelperMaterial source)
|
||||
{
|
||||
var targetMaterial = target as IElasticMaterial;
|
||||
var sourceMaterial = source as IElasticMaterial;
|
||||
var logic = new ElasticUpdateStrategy();
|
||||
logic.Update(targetMaterial, sourceMaterial);
|
||||
}
|
||||
private static void UpdateLibMaterial(IHelperMaterial target, IHelperMaterial source)
|
||||
{
|
||||
if (source is IConcreteLibMaterial)
|
||||
{
|
||||
var targetMaterial = target as IConcreteLibMaterial;
|
||||
var sourceMaterial = source as IConcreteLibMaterial;
|
||||
var logic = new ConcreteLibUpdateStrategy();
|
||||
logic.Update(targetMaterial, sourceMaterial);
|
||||
}
|
||||
else if (source is IReinforcementLibMaterial)
|
||||
{
|
||||
var targetMaterial = target as IReinforcementLibMaterial;
|
||||
var sourceMaterial = source as IReinforcementLibMaterial;
|
||||
var logic = new ReinforcementLibUpdateStrategy();
|
||||
logic.Update(targetMaterial, sourceMaterial);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"\n Expected: {typeof(ILibMaterial)},\n But was: {source.GetType()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class ReinforcementLibUpdateStrategy : IUpdateStrategy<IReinforcementLibMaterial>
|
||||
{
|
||||
LibMaterialUpdateStrategy libUpdateStrategy = new LibMaterialUpdateStrategy();
|
||||
public void Update(IReinforcementLibMaterial targetObject, IReinforcementLibMaterial sourceObject)
|
||||
{
|
||||
libUpdateStrategy.Update(targetObject, sourceObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -9,6 +9,7 @@ using Loadermaterials = LoaderCalculator.Data.Materials;
|
||||
using LMBuilders = LoaderCalculator.Data.Materials.MaterialBuilders;
|
||||
using LoaderMaterialLogics = LoaderCalculator.Data.Materials.MaterialBuilders.MaterialLogics;
|
||||
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class ReinforcementLibMaterial : IReinforcementLibMaterial
|
||||
@@ -29,7 +30,10 @@ namespace StructureHelperLogics.Models.Materials
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new ReinforcementLibMaterial() { MaterialEntity = MaterialEntity};
|
||||
var newItem = new ReinforcementLibMaterial();
|
||||
var updateStrategy = new ReinforcementLibUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
public Loadermaterials.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using LoaderCalculator.Logics;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public void Save()
|
||||
{
|
||||
repository.Save(this);
|
||||
repository.Create(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
using LoaderCalculator.Data.Ndms.Transformations;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
{
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using LoaderCalculator.Data.Materials.MaterialBuilders;
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.Forces;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
|
||||
Reference in New Issue
Block a user