using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Services;

namespace StructureHelperLogics.Models.Materials
{
    public class ConcreteLibUpdateStrategy : IUpdateStrategy<IConcreteLibMaterial>
    {
        private IUpdateStrategy<ILibMaterial> libUpdateStrategy;
        private IUpdateStrategy<ILibMaterial> LibUpdateStrategy => libUpdateStrategy ??= new LibMaterialUpdateStrategy();
        public ConcreteLibUpdateStrategy(IUpdateStrategy<ILibMaterial> libUpdateStrategy)
        {
            this.libUpdateStrategy = libUpdateStrategy;
        }
        public ConcreteLibUpdateStrategy()
        {
            
        }
        public void Update(IConcreteLibMaterial targetObject, IConcreteLibMaterial sourceObject)
        {
            CheckObject.ThrowIfNull(sourceObject);
            CheckObject.ThrowIfNull(targetObject);
            if (ReferenceEquals(targetObject, sourceObject)) { return; }
            LibUpdateStrategy.Update(targetObject, sourceObject);
            targetObject.TensionForULS = sourceObject.TensionForULS;
            targetObject.TensionForSLS = sourceObject.TensionForSLS;
            targetObject.RelativeHumidity = sourceObject.RelativeHumidity;
            targetObject.MinAge = sourceObject.MinAge;
            targetObject.MaxAge = sourceObject.MaxAge;
        }
    }
}
