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

@@ -27,5 +27,7 @@
public static string ObjectNotFound => "#0018: Object not found";
public static string ErrorDuring(string operation) => string.Format("Errors appeared during {0}, see detailed information", operation);
public static string CalculationError => "#0019: Error of calculation";
public static string SourceObject => "#0020: Source object";
public static string TargetObject => "#0021: Target object";
}
}

View File

@@ -0,0 +1,19 @@
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public abstract class BaseUpdateStrategy<T> : IUpdateStrategy<T>
{
public abstract void Update(T targetObject, T sourceObject);
public void Check(T targetObject, T sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
}
}
}

View File

@@ -17,7 +17,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public IShiftTraceLogger? TraceLogger { get; set; }
public IConvertStrategy<T,V> ConvertStrategy { get; set; }
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public T ConvertFrom(V source)
public T Convert(V source)
{
ICheckInputData();
T val;
@@ -31,32 +31,12 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
}
else
{
val = ConvertStrategy.ConvertFrom(source);
val = ConvertStrategy.Convert(source);
ReferenceDictionary.Add(key, val);
TraceLogger?.AddMessage($"New value of {typeof(T)} (Id = {val.Id}) was added to dictionary", TraceLogStatuses.Debug);
}
return val;
}
public V ConvertTo(T source)
{
ICheckInputData();
V val;
var key = (source.Id, typeof(V));
if (ReferenceDictionary.ContainsKey(key))
{
ISaveable existValue;
ReferenceDictionary.TryGetValue(key, out existValue);
val = (V)existValue;
TraceLogger?.AddMessage($"Value of {typeof(V)} (Id = {existValue.Id}) exists already", TraceLogStatuses.Debug);
}
else
{
val = ConvertStrategy.ConvertTo(source);
ReferenceDictionary.Add(key, val);
TraceLogger?.AddMessage($"New value of {typeof(V)} (Id = {val.Id}) was added to dictionary", TraceLogStatuses.Debug);
}
return val;
}
private void ICheckInputData()
{
if(ReferenceDictionary is null)

View File

@@ -11,8 +11,8 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
where T :ISaveable
where V :ISaveable
{
Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
IShiftTraceLogger TraceLogger { get; set; }
V ConvertTo(T source);
T ConvertFrom(V source);
T Convert(V source);
}
}

View File

@@ -0,0 +1,20 @@
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Implement center of geometry shape on 2D plane
/// </summary>
public interface IHasCenter2D
{
/// <summary>
/// 2D point of center
/// </summary>
IPoint2D Center {get;set;}
}
}