Add Cross-section repositort tests
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials.Logics
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates deep copy of internal elements of object which has materials
|
||||
/// </summary>
|
||||
public class HasMaterialsUpdateCloningStrategy : IUpdateStrategy<IHasHeadMaterials>
|
||||
{
|
||||
private ICloningStrategy cloningStrategy;
|
||||
|
||||
public HasMaterialsUpdateCloningStrategy(ICloningStrategy cloningStrategy)
|
||||
{
|
||||
this.cloningStrategy = cloningStrategy;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Update(IHasHeadMaterials targetObject, IHasHeadMaterials sourceObject)
|
||||
{
|
||||
CheckObject.IsNull(cloningStrategy);
|
||||
CheckObject.IsNull(sourceObject);
|
||||
CheckObject.IsNull(targetObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
targetObject.HeadMaterials.Clear();
|
||||
foreach (var material in sourceObject.HeadMaterials)
|
||||
{
|
||||
var newMaterial = cloningStrategy.Clone(material);
|
||||
targetObject.HeadMaterials.Add(newMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user