Add circle shape calculation for shear
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
internal class CircleShapeCloneStrategy : ICloneStrategy<ICircleShape>
|
||||
{
|
||||
IUpdateStrategy<ICircleShape> updateStrategy;
|
||||
public ICircleShape GetClone(ICircleShape sourceObject)
|
||||
{
|
||||
updateStrategy ??= new CircleShapeUpdateStrategy();
|
||||
CircleShape clone = new CircleShape(Guid.NewGuid());
|
||||
updateStrategy.Update(clone, sourceObject);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(ICircleShape targetObject, ICircleShape sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.Diameter = sourceObject.Diameter;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class RectangleShapeCloneStrategy : ICloneStrategy<IRectangleShape>
|
||||
{
|
||||
IUpdateStrategy<IRectangleShape> updateStrategy;
|
||||
public IRectangleShape GetClone(IRectangleShape sourceObject)
|
||||
{
|
||||
RectangleShape clone = new RectangleShape(Guid.NewGuid());
|
||||
updateStrategy ??= new RectangleShapeUpdateStrategy();
|
||||
updateStrategy.Update(clone, sourceObject);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Shapes
|
||||
{
|
||||
public class ShapeCloneStrategy : ICloneStrategy<IShape>
|
||||
{
|
||||
private ICloneStrategy<IRectangleShape> rectangleCloneStrategy;
|
||||
private ICloneStrategy<ICircleShape> circleCloneStrategy;
|
||||
public IShape GetClone(IShape sourceObject)
|
||||
{
|
||||
if (sourceObject is IRectangleShape rectangleShape)
|
||||
{
|
||||
rectangleCloneStrategy ??= new RectangleShapeCloneStrategy();
|
||||
return rectangleCloneStrategy.GetClone(rectangleShape);
|
||||
}
|
||||
else if (sourceObject is ICircleShape circleShape)
|
||||
{
|
||||
circleCloneStrategy ??= new CircleShapeCloneStrategy();
|
||||
return circleCloneStrategy.GetClone(circleShape);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(sourceObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user