Add circle shape calculation for shear
This commit is contained in:
@@ -43,7 +43,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearSectionUpdateStrategy();
|
||||
updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false};
|
||||
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
|
||||
(this, new ShapeFromDTOConvertStrategy(this));
|
||||
concreteConvertStrategy = new ConcreteLibMaterialFromDTOConvertStrategy()
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new BeamShearSectionUpdateStrategy();
|
||||
updateStrategy ??= new BeamShearSectionUpdateStrategy() { UpdateChildren = false};
|
||||
shapeConvertStrategy = new DictionaryConvertStrategy<IShape, IShape>
|
||||
(this, new ShapeToDTOConvertStrategy(this));
|
||||
concreteConvertStrategy = new ConcreteLibMaterialToDTOConvertStrategy()
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CircleShapeFromDTOConvertStrategy : ConvertStrategy<CircleShape, CircleShapeDTO>
|
||||
{
|
||||
private IUpdateStrategy<ICircleShape> updateStrategy;
|
||||
|
||||
public CircleShapeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override CircleShape GetNewItem(CircleShapeDTO source)
|
||||
{
|
||||
ChildClass = this;
|
||||
ChildClass = this;
|
||||
updateStrategy ??= new CircleShapeUpdateStrategy();
|
||||
NewItem = new CircleShape(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class CircleShapeToDTOConvertStrategy : ConvertStrategy<CircleShapeDTO, ICircleShape>
|
||||
{
|
||||
private IUpdateStrategy<ICircleShape> updateStrategy;
|
||||
|
||||
public CircleShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
public override CircleShapeDTO GetNewItem(ICircleShape source)
|
||||
{
|
||||
ChildClass = this;
|
||||
updateStrategy ??= new CircleShapeUpdateStrategy();
|
||||
NewItem = new(source.Id);
|
||||
updateStrategy.Update(NewItem, source);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace DataAccess.DTOs
|
||||
internal class ShapeFromDTOConvertStrategy : ConvertStrategy<IShape, IShape>
|
||||
{
|
||||
private IConvertStrategy<RectangleShape, RectangleShapeDTO> rectangleConvertStrategy;
|
||||
private IConvertStrategy<CircleShape, CircleShapeDTO> circleConvertStrategy;
|
||||
|
||||
public ShapeFromDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
@@ -14,12 +15,19 @@ namespace DataAccess.DTOs
|
||||
|
||||
public override IShape GetNewItem(IShape source)
|
||||
{
|
||||
ChildClass = this;
|
||||
if (source is RectangleShapeDTO rectangleShapeDTO)
|
||||
{
|
||||
rectangleConvertStrategy ??= new DictionaryConvertStrategy<RectangleShape, RectangleShapeDTO>
|
||||
(this, new RectangleShapeFromDTOConvertStrategy(this));
|
||||
NewItem = rectangleConvertStrategy.Convert(rectangleShapeDTO);
|
||||
}
|
||||
if (source is CircleShapeDTO circleShapeDTO)
|
||||
{
|
||||
circleConvertStrategy ??= new DictionaryConvertStrategy<CircleShape, CircleShapeDTO>
|
||||
(this, new CircleShapeFromDTOConvertStrategy(this));
|
||||
NewItem = circleConvertStrategy.Convert(circleShapeDTO);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape is unknown");
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace DataAccess.DTOs
|
||||
public class ShapeToDTOConvertStrategy : ConvertStrategy<IShape, IShape>
|
||||
{
|
||||
private IConvertStrategy<RectangleShapeDTO, IRectangleShape> rectangleConvertStrategy;
|
||||
private IConvertStrategy<CircleShapeDTO, ICircleShape> circleConvertStrategy;
|
||||
|
||||
public ShapeToDTOConvertStrategy(IBaseConvertStrategy baseConvertStrategy) : base(baseConvertStrategy)
|
||||
{
|
||||
@@ -15,16 +16,9 @@ namespace DataAccess.DTOs
|
||||
|
||||
public override IShape GetNewItem(IShape source)
|
||||
{
|
||||
try
|
||||
{
|
||||
GetNewShape(source);
|
||||
return NewItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TraceErrorByEntity(this, ex.Message);
|
||||
throw;
|
||||
}
|
||||
ChildClass = this;
|
||||
GetNewShape(source);
|
||||
return NewItem;
|
||||
}
|
||||
|
||||
private void GetNewShape(IShape source)
|
||||
@@ -34,6 +28,10 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
ProcessRectangle(rectangle);
|
||||
}
|
||||
else if (source is ICircleShape circle)
|
||||
{
|
||||
ProcessCircle(circle);
|
||||
}
|
||||
else
|
||||
{
|
||||
string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": shape type";
|
||||
@@ -42,6 +40,14 @@ namespace DataAccess.DTOs
|
||||
TraceLogger?.AddMessage($"Shape converting Id = {NewItem.Id} has been has been finished successfully", TraceLogStatuses.Debug);
|
||||
}
|
||||
|
||||
private void ProcessCircle(ICircleShape circle)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Shape is circle", TraceLogStatuses.Debug);
|
||||
circleConvertStrategy = new DictionaryConvertStrategy<CircleShapeDTO, ICircleShape>
|
||||
(this, new CircleShapeToDTOConvertStrategy(this));
|
||||
NewItem = circleConvertStrategy.Convert(circle);
|
||||
}
|
||||
|
||||
private void ProcessRectangle(IRectangleShape rectangle)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Shape is rectangle", TraceLogStatuses.Debug);
|
||||
|
||||
Reference in New Issue
Block a user