Add Force DTOs

This commit is contained in:
Evgeny Redikultsev
2024-10-12 21:30:21 +05:00
parent 2c5c5db43a
commit 7e54aa0407
64 changed files with 1237 additions and 216 deletions

View File

@@ -1,5 +1,6 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Loggers;
using System;
using System.Collections.Generic;
@@ -9,11 +10,22 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public class CheckConvertLogic<T, V> : ICheckLogic
where T : ISaveable
public class CheckConvertLogic<T, V> : ICheckConvertLogic<T, V> where T : ISaveable
where V : ISaveable
{
private string checkResult;
public CheckConvertLogic(IConvertStrategy<T, V> source)
{
ConvertStrategy = source;
TraceLogger = source.TraceLogger;
}
public CheckConvertLogic()
{
}
public IConvertStrategy<T, V> ConvertStrategy { get; set; }
public string CheckResult => checkResult;

View File

@@ -18,9 +18,20 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public IConvertStrategy<T,V> ConvertStrategy { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public DictionaryConvertStrategy(IBaseConvertStrategy baseConvertStrategy, IConvertStrategy<T, V> convertStrategy)
{
ReferenceDictionary = baseConvertStrategy.ReferenceDictionary;
TraceLogger = baseConvertStrategy.TraceLogger;
ConvertStrategy = convertStrategy;
}
public DictionaryConvertStrategy()
{
}
public T Convert(V source)
{
ICheckInputData();
CheckInputData();
T val;
var key = (source.Id, typeof(T));
if (ReferenceDictionary.ContainsKey(key))
@@ -38,7 +49,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
}
return val;
}
private void ICheckInputData()
private void CheckInputData()
{
if(ReferenceDictionary is null)
{
@@ -47,6 +58,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
throw new StructureHelperException(errorString);
}
}
}
}

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IBaseConvertStrategy
{
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
IShiftTraceLogger TraceLogger { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Models;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface ICheckConvertLogic<T, V> : ICheckLogic
where T : ISaveable
where V : ISaveable
{
IConvertStrategy<T, V> ConvertStrategy { get; set; }
IShiftTraceLogger? TraceLogger { get; set; }
}
}

View File

@@ -7,12 +7,10 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IConvertStrategy<T,V>
public interface IConvertStrategy<T,V> : IBaseConvertStrategy
where T :ISaveable
where V :ISaveable
{
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
IShiftTraceLogger TraceLogger { get; set; }
T Convert(V source);
}
}