Add VisualAnalysisDTO
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -17,6 +19,8 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
/// <inheritdoc />
|
||||
public void Update(IPoint2D targetObject, IPoint2D sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
|
||||
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.X = sourceObject.X;
|
||||
targetObject.Y = sourceObject.Y;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,6 +12,8 @@ namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public void Update(IRectangleShape targetObject, IRectangleShape sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Width = sourceObject.Width;
|
||||
targetObject.Height = sourceObject.Height;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes.Logics
|
||||
{
|
||||
public class ShapeUpdateStrategy : IUpdateStrategy<IShape>
|
||||
{
|
||||
public void Update(IShape targetObject, IShape sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
if (sourceObject is IRectangleShape sourceRectangle)
|
||||
{
|
||||
ProcessRectangles(targetObject, sourceRectangle);
|
||||
}
|
||||
else if (sourceObject is ICircleShape sourceCircle)
|
||||
{
|
||||
ProcessCircles(targetObject, sourceCircle);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessCircles(IShape targetObject, ICircleShape sourceCircle)
|
||||
{
|
||||
if (targetObject is ICircleShape targetCircle)
|
||||
{
|
||||
var updateLogic = new CircleShapeUpdateStrategy();
|
||||
updateLogic.Update(targetCircle, sourceCircle);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": target object is not circle");
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProcessRectangles(IShape targetObject, IRectangleShape sourceRectangle)
|
||||
{
|
||||
if (targetObject is IRectangleShape targetRectangle)
|
||||
{
|
||||
var updateLogic = new RectangleShapeUpdateStrategy();
|
||||
updateLogic.Update(targetRectangle, sourceRectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": target object is not rectangle");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user