// Copyright (C) Stichting Deltares 2016. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using Application.Ringtoets.Storage.DbContext; using Core.Common.Base.Data; using Ringtoets.Common.Data; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Structures; namespace Application.Ringtoets.Storage.Read { /// /// This class defines extension methods for read operations for the common code /// among all instances based on the . /// internal static class IStructureCalculationEntityReadExtensions { /// /// Reads all the information from the entity and updated the given input object, /// with the exception of the property. /// /// The type of structure residing in . /// The entity. /// The input object to update. /// The object keeping track of read operations. /// Thrown when /// or is null. public static void Read(this IStructuresCalculationEntity entity, StructuresInputBase inputToUpdate, ReadConversionCollector collector) where T : StructureBase { if (inputToUpdate == null) { throw new ArgumentNullException(nameof(inputToUpdate)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (entity.ForeshoreProfileEntity != null) { inputToUpdate.ForeshoreProfile = entity.ForeshoreProfileEntity.Read(collector); } if (entity.HydraulicLocationEntity != null) { inputToUpdate.HydraulicBoundaryLocation = entity.HydraulicLocationEntity.Read(collector); } inputToUpdate.StructureNormalOrientation = (RoundedDouble) entity.StructureNormalOrientation.ToNullAsNaN(); inputToUpdate.ModelFactorSuperCriticalFlow.Mean = (RoundedDouble) entity.ModelFactorSuperCriticalFlowMean.ToNullAsNaN(); inputToUpdate.AllowedLevelIncreaseStorage.Mean = (RoundedDouble) entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(); inputToUpdate.AllowedLevelIncreaseStorage.StandardDeviation = (RoundedDouble) entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN(); inputToUpdate.StorageStructureArea.Mean = (RoundedDouble) entity.StorageStructureAreaMean.ToNullAsNaN(); inputToUpdate.StorageStructureArea.CoefficientOfVariation = (RoundedDouble) entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN(); inputToUpdate.FlowWidthAtBottomProtection.Mean = (RoundedDouble) entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(); inputToUpdate.FlowWidthAtBottomProtection.StandardDeviation = (RoundedDouble) entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN(); inputToUpdate.CriticalOvertoppingDischarge.Mean = (RoundedDouble) entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(); inputToUpdate.CriticalOvertoppingDischarge.CoefficientOfVariation = (RoundedDouble) entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN(); inputToUpdate.FailureProbabilityStructureWithErosion = entity.FailureProbabilityStructureWithErosion; inputToUpdate.WidthFlowApertures.Mean = (RoundedDouble) entity.WidthFlowAperturesMean.ToNullAsNaN(); inputToUpdate.WidthFlowApertures.StandardDeviation = (RoundedDouble) entity.WidthFlowAperturesStandardDeviation.ToNullAsNaN(); inputToUpdate.StormDuration.Mean = (RoundedDouble) entity.StormDurationMean.ToNullAsNaN(); inputToUpdate.UseBreakWater = Convert.ToBoolean(entity.UseBreakWater); inputToUpdate.BreakWater.Type = (BreakWaterType) entity.BreakWaterType; inputToUpdate.BreakWater.Height = (RoundedDouble) entity.BreakWaterHeight.ToNullAsNaN(); inputToUpdate.UseForeshore = Convert.ToBoolean(entity.UseForeshore); } } }