UpdateStrategy for Actions was added
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ActionUpdateStrategy : IUpdateStrategy<IAction>
|
||||
{
|
||||
readonly IUpdateStrategy<IForceAction> forceUpdateStrategy = new ForceActionUpdateStrategy();
|
||||
public void Update(IAction targetObject, IAction sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.Name = sourceObject.Name;
|
||||
if (targetObject is IForceAction forceAction)
|
||||
{
|
||||
forceUpdateStrategy.Update(forceAction, (IForceAction)sourceObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(IAction), sourceObject.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class FactorCombinationUpdateStrategy : IUpdateStrategy<IForceCombinationByFactor>
|
||||
{
|
||||
readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy = new ForceTupleUpdateStrategy();
|
||||
public void Update(IForceCombinationByFactor targetObject, IForceCombinationByFactor sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
tupleUpdateStrategy.Update(targetObject.FullSLSForces, sourceObject.FullSLSForces);
|
||||
targetObject.ULSFactor = sourceObject.ULSFactor;
|
||||
targetObject.LongTermFactor = sourceObject.LongTermFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes.Logics;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForceActionUpdateStrategy : IUpdateStrategy<IForceAction>
|
||||
{
|
||||
private readonly IUpdateStrategy<IPoint2D> pointStrategy = new PointUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IDesignForcePair> forcePairUpdateStrategy = new ForcePairUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceCombinationByFactor> factorUpdateStrategy = new FactorCombinationUpdateStrategy();
|
||||
private readonly IUpdateStrategy<IForceCombinationList> forceListUpdateStrategy = new ForceCombinationListUpdateStrategy();
|
||||
public void Update(IForceAction targetObject, IForceAction sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.SetInGravityCenter = sourceObject.SetInGravityCenter;
|
||||
pointStrategy.Update(targetObject.ForcePoint, sourceObject.ForcePoint);
|
||||
UpdateChildProperties(targetObject, sourceObject);
|
||||
}
|
||||
|
||||
private void UpdateChildProperties(IForceAction targetObject, IForceAction sourceObject)
|
||||
{
|
||||
if (targetObject is IDesignForcePair pair)
|
||||
{
|
||||
forcePairUpdateStrategy.Update(pair, (IDesignForcePair)sourceObject);
|
||||
}
|
||||
else if (targetObject is IForceCombinationByFactor combination)
|
||||
{
|
||||
factorUpdateStrategy.Update(combination, (IForceCombinationByFactor)sourceObject);
|
||||
}
|
||||
else if (targetObject is IForceCombinationList forceCombinationList)
|
||||
{
|
||||
forceListUpdateStrategy.Update(forceCombinationList, (IForceCombinationList)sourceObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorCommonProcessor.ObjectTypeIsUnknown(typeof(IForceAction), targetObject.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForceCombinationListUpdateStrategy : IUpdateStrategy<IForceCombinationList>
|
||||
{
|
||||
public void Update(IForceCombinationList targetObject, IForceCombinationList sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
var forcesList = new List<IDesignForceTuple>(sourceObject.DesignForces);
|
||||
targetObject.DesignForces.Clear();
|
||||
foreach (var item in forcesList)
|
||||
{
|
||||
targetObject.DesignForces.Add((IDesignForceTuple)item.Clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Models.Shapes.Logics;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
public class ForcePairUpdateStrategy : IUpdateStrategy<IDesignForcePair>
|
||||
{
|
||||
private readonly IUpdateStrategy<IForceTuple> tupleUpdateStrategy = new ForceTupleUpdateStrategy();
|
||||
public void Update(IDesignForcePair targetObject, IDesignForcePair sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
targetObject.LimitState = sourceObject.LimitState;
|
||||
tupleUpdateStrategy.Update(targetObject.LongForceTuple, sourceObject.LongForceTuple);
|
||||
tupleUpdateStrategy.Update(targetObject.FullForceTuple, sourceObject.FullForceTuple);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Forces
|
||||
{
|
||||
internal class ForceTupleUpdateStrategy : IUpdateStrategy<IForceTuple>
|
||||
{
|
||||
public void Update(IForceTuple targetObject, IForceTuple sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, ": target object ");
|
||||
CheckObject.IsNull(sourceObject, ": source object ");
|
||||
|
||||
targetObject.Mx = sourceObject.Mx;
|
||||
targetObject.My = sourceObject.My;
|
||||
targetObject.Nz = targetObject.Nz;
|
||||
targetObject.Qx = targetObject.Qx;
|
||||
targetObject.Qy = targetObject.Qy;
|
||||
targetObject.Mz = sourceObject.Mz;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user