/// <summary> /// Sets the failure probability structure with erosion. /// </summary> /// <param name="readCalculation">The calculation read from the imported file.</param> /// <param name="calculation">The calculation to configure.</param> /// <returns><c>false</c> when the orientation is invalid or when there is a failure probability /// structure with erosion but no structure defined, <c>true</c> otherwise.</returns> private bool TrySetFailureProbabilityStructureWithErosion(StructuresCalculationConfiguration readCalculation, StructuresCalculation <ClosingStructuresInput> calculation) { if (readCalculation.FailureProbabilityStructureWithErosion.HasValue) { double failureProbability = readCalculation.FailureProbabilityStructureWithErosion.Value; try { calculation.InputParameters.FailureProbabilityStructureWithErosion = (RoundedDouble)failureProbability; } catch (ArgumentOutOfRangeException e) { Log.LogOutOfRangeException( string.Format( RiskeerCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid, failureProbability, RiskeerCommonIOResources.CalculationConfigurationImporter_FailureProbabilityStructureWithErosion_DisplayName), calculation.Name, e); return(false); } } return(true); }
/// <summary> /// Sets the orientation. /// </summary> /// <param name="readCalculation">The calculation read from the imported file.</param> /// <param name="calculation">The calculation to configure.</param> /// <returns><c>false</c> when the orientation is invalid or when there is an orientation but /// no structure defined, <c>true</c> otherwise.</returns> private bool TrySetOrientation(StructuresCalculationConfiguration readCalculation, StructuresCalculation <HeightStructuresInput> calculation) { if (readCalculation.StructureNormalOrientation.HasValue) { if (calculation.InputParameters.Structure == null) { Log.LogCalculationConversionError( string.Format(RiskeerCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_, RiskeerCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName), calculation.Name); return(false); } double orientation = readCalculation.StructureNormalOrientation.Value; try { calculation.InputParameters.StructureNormalOrientation = (RoundedDouble)orientation; } catch (ArgumentOutOfRangeException e) { Log.LogOutOfRangeException( string.Format(RiskeerCommonIOResources.TryReadParameter_Value_0_ParameterName_1_is_invalid, orientation, RiskeerCommonIOResources.CalculationConfigurationImporter_Orientation_DisplayName), calculation.Name, e); return(false); } } return(true); }
/// <summary> /// Sets the <paramref name="configuration"/> using properties from <paramref name="input"/>, /// when <see cref="StructuresInputBase{StructureBase}.ForeshoreProfile"/> is set. /// </summary> /// <typeparam name="T">The type of structure for <paramref name="input"/>.</typeparam> /// <param name="configuration">The configuration to update.</param> /// <param name="input">The structure input to update from.</param> /// <exception cref="ArgumentNullException">Thrown when any of the input parameters is <c>null</c>.</exception> public static void SetConfigurationForeshoreProfileDependentProperties <T>(this StructuresCalculationConfiguration configuration, StructuresInputBase <T> input) where T : StructureBase { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (input == null) { throw new ArgumentNullException(nameof(input)); } if (input.ForeshoreProfile == null) { return; } configuration.ForeshoreProfileId = input.ForeshoreProfile?.Id; configuration.WaveReduction = new WaveReductionConfiguration { UseForeshoreProfile = input.UseForeshore, UseBreakWater = input.UseBreakWater, BreakWaterHeight = input.BreakWater.Height }; if (Enum.IsDefined(typeof(BreakWaterType), input.BreakWater.Type)) { configuration.WaveReduction.BreakWaterType = (ConfigurationBreakWaterType?) new ConfigurationBreakWaterTypeConverter().ConvertFrom(input.BreakWater.Type); } }