Add VisualAnalysisDTO

This commit is contained in:
Evgeny Redikultsev
2024-09-14 19:03:35 +05:00
parent 5a9e7c3c4f
commit c10d6eb94e
84 changed files with 958 additions and 410 deletions

View File

@@ -52,6 +52,15 @@ namespace DataAccess.Infrastructures
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
FileVersionDTO versionDTO = GetVersionDTO();
var versionString = Serialize(versionDTO, TraceLogger);
SaveStringToFile(project, versionString);
refDictinary = new Dictionary<(Guid id, Type type), ISaveable>();
ProjectDTO projectDTO = GetProjectDTO(project);
var projectString = Serialize(projectDTO, TraceLogger);
SaveStringToFile(project, projectString);
}
private void SaveStringToFile(IProject project, string versionString)
{
try
{
File.WriteAllText(project.FullFileName, versionString);
@@ -63,19 +72,36 @@ namespace DataAccess.Infrastructures
}
}
private FileVersionDTO GetVersionDTO()
private ProjectDTO GetProjectDTO(IProject project)
{
FileVersionDTOConvertStrategy fileVersionDTOConvertStrategy = new()
ProjectToDTOConvertStrategy convertStrategy = new()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
DictionaryConvertStrategy<FileVersion, FileVersionDTO> dictionaryConvertStrategy = new()
DictionaryConvertStrategy<ProjectDTO, IProject> dictionaryConvertStrategy = new()
{
ConvertStrategy = convertStrategy,
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
return dictionaryConvertStrategy.Convert(project);
}
private FileVersionDTO GetVersionDTO()
{
FileVersionToDTOConvertStrategy fileVersionDTOConvertStrategy = new()
{
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
DictionaryConvertStrategy<FileVersionDTO,IFileVersion> dictionaryConvertStrategy = new()
{
ConvertStrategy = fileVersionDTOConvertStrategy,
ReferenceDictionary = refDictinary,
TraceLogger = TraceLogger
};
var versionDTO = dictionaryConvertStrategy.ConvertTo(version as FileVersion);
var versionDTO = dictionaryConvertStrategy.Convert(version);
return versionDTO;
}
@@ -85,8 +111,9 @@ namespace DataAccess.Infrastructures
{
Converters = new List<JsonConverter>
{
new FileVersionDTOJsonConverter(logger), // Add the specific converter
// Add other converters if needed
new FileVersionDTOJsonConverter(logger), // Add the specific converter
new ProjectDTOJsonConverter(logger)
},
Formatting = Formatting.Indented,
PreserveReferencesHandling = PreserveReferencesHandling.All,