Add cross-section convert strategies
This commit is contained in:
@@ -8,13 +8,18 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSection : ICrossSection
|
||||
{
|
||||
public ICrossSectionRepository SectionRepository { get; private set; }
|
||||
public ICrossSectionRepository SectionRepository { get; private set; } = new CrossSectionRepository();
|
||||
|
||||
public Guid Id { get; private set; }
|
||||
|
||||
public CrossSection()
|
||||
public CrossSection(Guid id)
|
||||
{
|
||||
SectionRepository = new CrossSectionRepository();
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public CrossSection() : this(Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
|
||||
@@ -14,17 +14,19 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSectionRepository : ICrossSectionRepository
|
||||
{
|
||||
public List<IForceAction> ForceActions { get; private set; }
|
||||
public List<IHeadMaterial> HeadMaterials { get; private set; }
|
||||
public List<INdmPrimitive> Primitives { get; }
|
||||
public List<ICalculator> CalculatorsList { get; private set; }
|
||||
public Guid Id { get; }
|
||||
public List<IForceAction> ForceActions { get; private set; } = new();
|
||||
public List<IHeadMaterial> HeadMaterials { get; private set; } = new();
|
||||
public List<INdmPrimitive> Primitives { get; } = new();
|
||||
public List<ICalculator> Calculators { get; private set; } = new();
|
||||
|
||||
public CrossSectionRepository()
|
||||
public CrossSectionRepository(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public CrossSectionRepository() : this(Guid.NewGuid())
|
||||
{
|
||||
ForceActions = new List<IForceAction>();
|
||||
HeadMaterials = new List<IHeadMaterial>();
|
||||
Primitives = new List<INdmPrimitive>();
|
||||
CalculatorsList = new List<ICalculator>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,18 +12,29 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public class CrossSectionUpdateStrategy : IUpdateStrategy<ICrossSection>
|
||||
{
|
||||
private IUpdateStrategy<ICrossSectionRepository> repositoryUpdateStrategy;
|
||||
|
||||
public CrossSectionUpdateStrategy()
|
||||
public CrossSectionUpdateStrategy(IUpdateStrategy<ICrossSectionRepository> repositoryUpdateStrategy)
|
||||
{
|
||||
this.repositoryUpdateStrategy = repositoryUpdateStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionUpdateStrategy() : this (
|
||||
new CrossSectionRepositoryUpdateStrategy()
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(ICrossSection targetObject, ICrossSection sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
|
||||
targetObject.SectionRepository.Calculators.Clear();
|
||||
targetObject.SectionRepository.Primitives.Clear();
|
||||
targetObject.SectionRepository.ForceActions.Clear();
|
||||
targetObject.SectionRepository.HeadMaterials.Clear();
|
||||
repositoryUpdateStrategy.Update(targetObject.SectionRepository, sourceObject.SectionRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.CrossSections
|
||||
{
|
||||
public interface ICrossSectionRepository : IHasHeadMaterials, IHasPrimitives, IHasForceCombinations
|
||||
public interface ICrossSectionRepository : ISaveable, IHasHeadMaterials, IHasPrimitives, IHasForceCombinations, IHasCalculators
|
||||
{
|
||||
List<IForceAction> ForceActions { get; }
|
||||
List<ICalculator> CalculatorsList { get; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user