Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs =================================================================== diff -u -r998fa47a674768b67849e33a5a43767a6374b7a0 -red611dc641e6c7e1e5906ffe81a40b79f78f68d7 --- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs (.../ClosingStructuresCalculationsView.cs) (revision 998fa47a674768b67849e33a5a43767a6374b7a0) +++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Forms/Views/ClosingStructuresCalculationsView.cs (.../ClosingStructuresCalculationsView.cs) (revision ed611dc641e6c7e1e5906ffe81a40b79f78f68d7) @@ -67,6 +67,10 @@ /// /// Creates a new instance of . /// + /// The data. + /// The failure mechanism. + /// The assessment section. + /// Thrown when any parameter is null. public ClosingStructuresCalculationsView(CalculationGroup data, ClosingStructuresFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { if (data == null) @@ -164,7 +168,7 @@ dataGridViewControl.AddComboBoxColumn(nameof(ClosingStructuresCalculationRow.BreakWaterType), RiskeerCommonFormsResources.CalculationsView_BreakWaterType_DisplayName, - GetBreakWaterTypes(), + GetEnumTypes(), nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); @@ -177,7 +181,7 @@ dataGridViewControl.AddComboBoxColumn(nameof(ClosingStructuresCalculationRow.InflowModelType), RiskeerCommonFormsResources.Structure_InflowModelType_DisplayName, - GetInflowModelTypes(), + GetEnumTypes(), nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); @@ -296,8 +300,7 @@ dataGridViewControl.AutoResizeColumns(); } - var failureMechanismSection = listBox.SelectedItem as FailureMechanismSection; - if (failureMechanismSection == null || calculationGroup == null) + if (!(listBox.SelectedItem is FailureMechanismSection failureMechanismSection)) { dataGridViewControl.SetDataSource(null); return; @@ -429,22 +432,14 @@ } } - private static IEnumerable> GetBreakWaterTypes() + private static IEnumerable> GetEnumTypes() { - return Enum.GetValues(typeof(BreakWaterType)) - .OfType() - .Select(bwt => new EnumDisplayWrapper(bwt)) + return Enum.GetValues(typeof(T)) + .OfType() + .Select(et => new EnumDisplayWrapper(et)) .ToArray(); } - private static IEnumerable> GetInflowModelTypes() - { - return Enum.GetValues(typeof(ClosingStructureInflowModelType)) - .OfType() - .Select(imt => new EnumDisplayWrapper(imt)) - .ToArray(); - } - private IEnumerable GetSelectableHydraulicBoundaryLocationsFromFailureMechanism() { List hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryDatabase.Locations; @@ -509,7 +504,7 @@ { listBox.Items.Clear(); - if (failureMechanism != null && failureMechanism.Sections.Any()) + if (failureMechanism.Sections.Any()) { listBox.Items.AddRange(failureMechanism.Sections.Cast().ToArray()); listBox.SelectedItem = failureMechanism.Sections.First(); Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationsView.cs =================================================================== diff -u -r46b96a8bc87091274e3537e8bb5ca21aa0a6d04b -red611dc641e6c7e1e5906ffe81a40b79f78f68d7 --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationsView.cs (.../GrassCoverErosionInwardsCalculationsView.cs) (revision 46b96a8bc87091274e3537e8bb5ca21aa0a6d04b) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsCalculationsView.cs (.../GrassCoverErosionInwardsCalculationsView.cs) (revision ed611dc641e6c7e1e5906ffe81a40b79f78f68d7) @@ -167,7 +167,7 @@ dataGridViewControl.AddComboBoxColumn(nameof(GrassCoverErosionInwardsCalculationRow.BreakWaterType), RiskeerCommonFormsResources.CalculationsView_BreakWaterType_DisplayName, - GetBreakWaterTypes(), + GetEnumTypes(), nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); @@ -419,11 +419,11 @@ } } - private static IEnumerable> GetBreakWaterTypes() + private static IEnumerable> GetEnumTypes() { - return Enum.GetValues(typeof(BreakWaterType)) - .OfType() - .Select(bwt => new EnumDisplayWrapper(bwt)) + return Enum.GetValues(typeof(T)) + .OfType() + .Select(et => new EnumDisplayWrapper(et)) .ToArray(); }