Add Force DTOs
This commit is contained in:
@@ -9,11 +9,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class ElasticUpdateStrategy : IUpdateStrategy<IElasticMaterial>
|
||||
public class ElasticUpdateStrategy : IUpdateStrategy<IElasticMaterial>
|
||||
{
|
||||
public void Update(IElasticMaterial targetObject, IElasticMaterial sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Modulus = sourceObject.Modulus;
|
||||
targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
|
||||
|
||||
@@ -9,11 +9,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal class FRUpdateStrategy : IUpdateStrategy<IFRMaterial>
|
||||
/// <inheritdoc/>
|
||||
public class FRUpdateStrategy : IUpdateStrategy<IFRMaterial>
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public void Update(IFRMaterial targetObject, IFRMaterial sourceObject)
|
||||
{
|
||||
CheckObject.ReferenceEquals(targetObject, sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Modulus = sourceObject.Modulus;
|
||||
targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials.Logics
|
||||
{
|
||||
public class HelpermaterialSafetyFactorsUpdateStrategy : IUpdateStrategy<IHelperMaterial>
|
||||
{
|
||||
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
if (sourceObject.SafetyFactors is not null)
|
||||
{
|
||||
if (targetObject.SafetyFactors is null)
|
||||
{
|
||||
targetObject.SafetyFactors = new();
|
||||
}
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var item in sourceObject.SafetyFactors)
|
||||
{
|
||||
targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.Materials.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -15,6 +17,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
private IUpdateStrategy<IFRMaterial> frStrategy;
|
||||
private IUpdateStrategy<IConcreteLibMaterial> concreteStrategy;
|
||||
private IUpdateStrategy<IReinforcementLibMaterial> reinforcementStrategy;
|
||||
private IUpdateStrategy<IHelperMaterial> safetyFactorUpdateStrategy = new HelpermaterialSafetyFactorsUpdateStrategy();
|
||||
public HelperMaterialUpdateStrategy(IUpdateStrategy<IElasticMaterial> elasticStrategy,
|
||||
IUpdateStrategy<IFRMaterial> frStrategy,
|
||||
IUpdateStrategy<IConcreteLibMaterial> concreteStrategy,
|
||||
@@ -38,6 +41,8 @@ namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
safetyFactorUpdateStrategy.Update(targetObject, sourceObject);
|
||||
if (sourceObject is ILibMaterial)
|
||||
{
|
||||
UpdateLibMaterial(targetObject, sourceObject);
|
||||
|
||||
@@ -17,18 +17,6 @@ namespace StructureHelperLogics.Models.Materials
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.MaterialEntity = sourceObject.MaterialEntity;
|
||||
if (sourceObject.SafetyFactors is not null)
|
||||
{
|
||||
if (targetObject.SafetyFactors is null)
|
||||
{
|
||||
targetObject.SafetyFactors = new();
|
||||
}
|
||||
targetObject.SafetyFactors.Clear();
|
||||
foreach (var item in sourceObject.SafetyFactors)
|
||||
{
|
||||
targetObject.SafetyFactors.Add(item.Clone() as IMaterialSafetyFactor);
|
||||
}
|
||||
}
|
||||
targetObject.MaterialLogic = sourceObject.MaterialLogic;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user