Add VisualAnalysisDTO
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FileVersionFromDTOConvertStrategy : IConvertStrategy<FileVersion, FileVersionDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public FileVersionFromDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
public FileVersionFromDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FileVersion Convert(FileVersionDTO source)
|
||||
{
|
||||
FileVersion fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FileVersionToDTOConvertStrategy : IConvertStrategy<FileVersionDTO, IFileVersion>
|
||||
{
|
||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
|
||||
public FileVersionToDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
public FileVersionToDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FileVersionDTO Convert(IFileVersion source)
|
||||
{
|
||||
FileVersionDTO fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs
Normal file
51
DataAccess/DTOs/Converters/ProjectToDTOConvertStrategy.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class ProjectToDTOConvertStrategy : IConvertStrategy<ProjectDTO, IProject>
|
||||
{
|
||||
private IUpdateStrategy<IProject> updateStrategy;
|
||||
private IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy;
|
||||
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public ProjectToDTOConvertStrategy(IUpdateStrategy<IProject> updateStrategy, IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis> convertStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
this.convertStrategy = convertStrategy;
|
||||
}
|
||||
|
||||
public ProjectToDTOConvertStrategy() : this(new ProjectUpdateStrategy(), new VisualAnalysisToDTOConvertStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ProjectDTO Convert(IProject source)
|
||||
{
|
||||
ProjectDTO projectDTO = new(source.Id);
|
||||
updateStrategy.Update(projectDTO, source);
|
||||
convertStrategy.ReferenceDictionary = ReferenceDictionary;
|
||||
var convertLogic = new DictionaryConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>()
|
||||
{
|
||||
ReferenceDictionary = ReferenceDictionary,
|
||||
ConvertStrategy = convertStrategy,
|
||||
TraceLogger = TraceLogger
|
||||
};
|
||||
foreach (var item in source.VisualAnalyses)
|
||||
{
|
||||
var newVisualAnalysis = convertLogic.Convert(item);
|
||||
projectDTO.VisualAnalyses.Add(newVisualAnalysis);
|
||||
}
|
||||
return projectDTO;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
internal class VisualAnalysisToDTOConvertStrategy : IConvertStrategy<VisualAnalysisDTO, IVisualAnalysis>
|
||||
{
|
||||
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public VisualAnalysisDTO Convert(IVisualAnalysis source)
|
||||
{
|
||||
VisualAnalysisDTO visualAnalysisDTO = new()
|
||||
{
|
||||
Id = source.Id
|
||||
};
|
||||
return visualAnalysisDTO;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class FileVersionDTOConvertStrategy : IConvertStrategy<FileVersion, FileVersionDTO>
|
||||
{
|
||||
private IUpdateStrategy<IFileVersion> updateStrategy;
|
||||
|
||||
public IShiftTraceLogger TraceLogger { get; set; }
|
||||
|
||||
public FileVersionDTOConvertStrategy(IUpdateStrategy<IFileVersion> updateStrategy)
|
||||
{
|
||||
this.updateStrategy = updateStrategy;
|
||||
}
|
||||
public FileVersionDTOConvertStrategy() : this(new FileVersionUpdateStrategy())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public FileVersionDTO ConvertTo(FileVersion source)
|
||||
{
|
||||
FileVersionDTO fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
|
||||
public FileVersion ConvertFrom(FileVersionDTO source)
|
||||
{
|
||||
FileVersion fileVersion = new(source.Id);
|
||||
updateStrategy.Update(fileVersion, source);
|
||||
return fileVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,8 +15,6 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("Center")]
|
||||
public IPoint2D Center { get; set; }
|
||||
[JsonProperty("HeadMaterial")]
|
||||
public IHeadMaterial? HeadMaterial { get; set; }
|
||||
[JsonProperty("Triangulate")]
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace DataAccess.DTOs
|
||||
public bool IsActual { get; set; }
|
||||
|
||||
[JsonProperty("VisualAnalyses")]
|
||||
public List<IVisualAnalysis> VisualAnalyses { get; private set; }
|
||||
public List<IVisualAnalysis> VisualAnalyses { get; private set; } = new();
|
||||
|
||||
[JsonIgnore]
|
||||
public string FileName { get; set; }
|
||||
@@ -31,5 +31,10 @@ namespace DataAccess.DTOs
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public ProjectDTO() : this (Guid.NewGuid())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
29
DataAccess/DTOs/VisualAnalysisDTO.cs
Normal file
29
DataAccess/DTOs/VisualAnalysisDTO.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Newtonsoft.Json;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class VisualAnalysisDTO : IVisualAnalysis
|
||||
{
|
||||
|
||||
[JsonProperty("Id")]
|
||||
public Guid Id { get; set; }
|
||||
[JsonProperty("Analysis")]
|
||||
public IAnalysis Analysis { get; set; }
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user