Add VisualAnalysisDTO
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogic.Models.Analyses
|
||||
{
|
||||
public class CrossSectionNdmAnalysis : IAnalysis
|
||||
{
|
||||
private CrossSectionNdmAnalysisUpdateStrategy updateStrategy = new();
|
||||
public Guid Id { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public string Tags { get; set; }
|
||||
@@ -21,7 +18,7 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
VersionProcessor = versionProcessor;
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysis() : this(new Guid(), new VersionProcessor())
|
||||
public CrossSectionNdmAnalysis() : this(Guid.NewGuid(), new VersionProcessor())
|
||||
{
|
||||
CrossSection crossSection = new CrossSection();
|
||||
VersionProcessor.AddVersion(crossSection);
|
||||
@@ -29,7 +26,9 @@ namespace StructureHelperLogic.Models.Analyses
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CrossSectionNdmAnalysis newAnalysis = new();
|
||||
updateStrategy.Update(newAnalysis, this);
|
||||
return newAnalysis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Analyses
|
||||
{
|
||||
public class CrossSectionNdmAnalysisUpdateStrategy : IUpdateStrategy<CrossSectionNdmAnalysis>
|
||||
{
|
||||
private IUpdateStrategy<IAnalysis> analysisUpdateStrategy;
|
||||
private IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy;
|
||||
private IUpdateStrategy<IDateVersion> dateUpdateStrategy;
|
||||
|
||||
public CrossSectionNdmAnalysisUpdateStrategy(IUpdateStrategy<IAnalysis> analysisUpdateStrategy,
|
||||
IUpdateStrategy<ICrossSection> crossSectionUpdateStrategy,
|
||||
IUpdateStrategy<IDateVersion> dateUpdateStrategy)
|
||||
{
|
||||
this.analysisUpdateStrategy = analysisUpdateStrategy;
|
||||
this.crossSectionUpdateStrategy = crossSectionUpdateStrategy;
|
||||
this.dateUpdateStrategy = dateUpdateStrategy;
|
||||
}
|
||||
|
||||
public CrossSectionNdmAnalysisUpdateStrategy() : this(
|
||||
new AnalysisUpdateStrategy(),
|
||||
new CrossSectionUpdateStrategy(),
|
||||
new DateVersionUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(CrossSectionNdmAnalysis targetObject, CrossSectionNdmAnalysis sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
|
||||
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; };
|
||||
analysisUpdateStrategy.Update(targetObject, sourceObject);
|
||||
targetObject.VersionProcessor.Versions.Clear();
|
||||
foreach (var version in sourceObject.VersionProcessor.Versions)
|
||||
{
|
||||
if (version.Item is ICrossSection crossSection)
|
||||
{
|
||||
updateVersion(targetObject, version, crossSection);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version.Item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVersion(CrossSectionNdmAnalysis targetObject, IDateVersion version, ICrossSection crossSection)
|
||||
{
|
||||
DateVersion newVersion = new();
|
||||
dateUpdateStrategy.Update(newVersion, version);
|
||||
CrossSection newCrossection = new();
|
||||
crossSectionUpdateStrategy.Update(newCrossection, crossSection);
|
||||
newVersion.Item = newCrossection;
|
||||
targetObject.VersionProcessor.Versions.Add(newVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user