Add primitive visual property
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
@@ -10,6 +11,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
public HasStirrupsFromDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
@@ -63,7 +65,8 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
|
||||
}
|
||||
|
||||
visualUpdateStrategy = new HasVisualPropertyFromDTOUpdateStrategy(referenceDictionary, traceLogger);
|
||||
visualUpdateStrategy.Update(newItem, stirrup);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
|
||||
@@ -10,6 +11,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IUpdateStrategy<IHasVisualProperty> visualUpdateStrategy;
|
||||
|
||||
public HasStirrupsToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
@@ -64,6 +66,8 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrup));
|
||||
}
|
||||
visualUpdateStrategy = new HasVisualPropertyToDTOUpdateStrategy(referenceDictionary, traceLogger);
|
||||
visualUpdateStrategy.Update(newItem, stirrup);
|
||||
return newItem;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
@@ -14,6 +15,7 @@ namespace DataAccess.DTOs
|
||||
{
|
||||
private IUpdateStrategy<IStirrupByInclinedRebar> updateStrategy;
|
||||
private IConvertStrategy<RebarSectionDTO, IRebarSection> rebarConvertStrategy;
|
||||
|
||||
|
||||
public StirrupByInclinedRebarToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.Models.BeamShears.Logics;
|
||||
using System;
|
||||
@@ -15,6 +16,7 @@ namespace DataAccess.DTOs
|
||||
private IUpdateStrategy<IStirrupGroup> updateStrategy;
|
||||
private IUpdateStrategy<IHasStirrups> stirrupUpdateStrategy;
|
||||
|
||||
|
||||
public StirrupGroupToDTOConvertStrategy(
|
||||
Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
||||
IShiftTraceLogger traceLogger)
|
||||
@@ -34,7 +36,7 @@ namespace DataAccess.DTOs
|
||||
|
||||
private void InitializeStrategies()
|
||||
{
|
||||
updateStrategy ??= new StirrupGroupUpdateStrategy();
|
||||
updateStrategy ??= new StirrupGroupUpdateStrategy() { UpdateChildren = false};
|
||||
stirrupUpdateStrategy ??= new HasStirrupsToDTOUpdateStrategy(ReferenceDictionary, TraceLogger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasVisualPropertyFromDTOUpdateStrategy : IUpdateStrategy<IHasVisualProperty>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO> convertStrategy;
|
||||
|
||||
public HasVisualPropertyFromDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasVisualProperty targetObject, IHasVisualProperty sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
convertStrategy = new DictionaryConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO>(
|
||||
referenceDictionary,
|
||||
traceLogger,
|
||||
new PrimitiveVisualPropertyFromDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
if (sourceObject.VisualProperty is not PrimitiveVisualPropertyDTO visualProperty)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(sourceObject.VisualProperty));
|
||||
}
|
||||
targetObject.VisualProperty = convertStrategy.Convert(visualProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class HasVisualPropertyToDTOUpdateStrategy : IUpdateStrategy<IHasVisualProperty>
|
||||
{
|
||||
private Dictionary<(Guid id, Type type), ISaveable> referenceDictionary;
|
||||
private IShiftTraceLogger traceLogger;
|
||||
private IConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty> convertStrategy;
|
||||
|
||||
public HasVisualPropertyToDTOUpdateStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger)
|
||||
{
|
||||
this.referenceDictionary = referenceDictionary;
|
||||
this.traceLogger = traceLogger;
|
||||
}
|
||||
|
||||
public void Update(IHasVisualProperty targetObject, IHasVisualProperty sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(targetObject);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
convertStrategy = new DictionaryConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty>(
|
||||
referenceDictionary,
|
||||
traceLogger,
|
||||
new PrimitiveVisualPropertyToDTOConvertStrategy(referenceDictionary, traceLogger));
|
||||
targetObject.VisualProperty = convertStrategy.Convert(sourceObject.VisualProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
internal class PrimitiveVisualPropertyFromDTOConvertStrategy : ConvertStrategy<PrimitiveVisualProperty, PrimitiveVisualPropertyDTO>
|
||||
{
|
||||
private IUpdateStrategy<IPrimitiveVisualProperty> _updateStrategy;
|
||||
|
||||
public PrimitiveVisualPropertyFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override PrimitiveVisualProperty GetNewItem(PrimitiveVisualPropertyDTO source)
|
||||
{
|
||||
_updateStrategy ??= new PrimitiveVisualPropertyUpdateStrategy();
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.VisualProperties;
|
||||
|
||||
namespace DataAccess.DTOs
|
||||
{
|
||||
public class PrimitiveVisualPropertyToDTOConvertStrategy : ConvertStrategy<PrimitiveVisualPropertyDTO, IPrimitiveVisualProperty>
|
||||
{
|
||||
private IUpdateStrategy<IPrimitiveVisualProperty> _updateStrategy;
|
||||
|
||||
public PrimitiveVisualPropertyToDTOConvertStrategy(
|
||||
Dictionary<(Guid id, Type type), ISaveable> referenceDictionary,
|
||||
IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger)
|
||||
{
|
||||
}
|
||||
|
||||
public override PrimitiveVisualPropertyDTO GetNewItem(IPrimitiveVisualProperty source)
|
||||
{
|
||||
_updateStrategy ??= new PrimitiveVisualPropertyUpdateStrategy();
|
||||
ChildClass = this;
|
||||
NewItem = new(source.Id);
|
||||
return NewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace DataAccess.DTOs
|
||||
(this, new RectangleShapeFromDTOConvertStrategy(this));
|
||||
NewItem = rectangleConvertStrategy.Convert(rectangleShapeDTO);
|
||||
}
|
||||
if (source is CircleShapeDTO circleShapeDTO)
|
||||
else if (source is CircleShapeDTO circleShapeDTO)
|
||||
{
|
||||
circleConvertStrategy ??= new DictionaryConvertStrategy<CircleShape, CircleShapeDTO>
|
||||
(this, new CircleShapeFromDTOConvertStrategy(this));
|
||||
|
||||
Reference in New Issue
Block a user