Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs =================================================================== diff -u -rd77847d0615cd770516f4a3f32628756d56faf2a -r6351c078e52e7a091c3307337ba66e18fde91525 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision d77847d0615cd770516f4a3f32628756d56faf2a) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 6351c078e52e7a091c3307337ba66e18fde91525) @@ -34,37 +34,47 @@ /// /// The view for the . /// - /// The type of results which are presented by the . - public abstract partial class FailureMechanismResultView : UserControl, IView where T : FailureMechanismSectionResult + /// The type of the failure mechanism this view belongs to. + /// The type of results which are presented by the + /// . + public abstract partial class FailureMechanismResultView : UserControl, IView + where TSectionResult : FailureMechanismSectionResult + where TFailureMechanism : FailureMechanismBase { protected const int AssessmentLayerOneColumnIndex = 1; private readonly Observer failureMechanismSectionResultObserver; - private readonly IObservableEnumerable failureMechanismSectionResults; - private readonly RecursiveObserver, T> failureMechanismSectionResultsObserver; + private readonly IObservableEnumerable failureMechanismSectionResults; + private readonly RecursiveObserver, TSectionResult> failureMechanismSectionResultsObserver; /// - /// Creates a new instance of . + /// Creates a new instance of . /// - /// The collection of to + /// The failure mechanism this view belongs to. + /// The collection of to /// show in the view. - /// Thrown when - /// is null. - protected FailureMechanismResultView(IObservableEnumerable failureMechanismSectionResults) + /// Thrown when any input parameter is null. + protected FailureMechanismResultView(TFailureMechanism failureMechanism, IObservableEnumerable failureMechanismSectionResults) { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + if (failureMechanismSectionResults == null) { throw new ArgumentNullException(nameof(failureMechanismSectionResults)); } InitializeComponent(); + FailureMechanism = failureMechanism; this.failureMechanismSectionResults = failureMechanismSectionResults; failureMechanismSectionResultObserver = new Observer(UpdateDataGridViewDataSource) { Observable = failureMechanismSectionResults }; - failureMechanismSectionResultsObserver = new RecursiveObserver, T>( + failureMechanismSectionResultsObserver = new RecursiveObserver, TSectionResult>( DataGridViewControl.RefreshDataGridView, sr => sr) { @@ -73,9 +83,9 @@ } /// - /// Sets the failure mechanism. + /// Gets the failure mechanism. /// - public virtual IFailureMechanism FailureMechanism { protected get; set; } + public TFailureMechanism FailureMechanism { get; } public object Data { get; set; } @@ -89,12 +99,12 @@ /// /// Creates a display object for which is added to the - /// on the . + /// on the . /// - /// The for which to create a + /// The for which to create a /// display object. /// A display object which can be added as a row to the . - protected abstract object CreateFailureMechanismSectionResultRow(T sectionResult); + protected abstract object CreateFailureMechanismSectionResultRow(TSectionResult sectionResult); protected override void Dispose(bool disposing) { @@ -151,7 +161,7 @@ protected virtual void AddDataGridColumns() { DataGridViewControl.AddTextBoxColumn( - nameof(FailureMechanismSectionResultRow.Name), + nameof(FailureMechanismSectionResultRow.Name), Resources.FailureMechanismResultView_InitializeDataGridView_Section_name, true); @@ -162,7 +172,7 @@ .ToArray(); DataGridViewControl.AddComboBoxColumn( - nameof(FailureMechanismSectionResultRow.AssessmentLayerOne), + nameof(FailureMechanismSectionResultRow.AssessmentLayerOne), Resources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, oneStateDataSource, nameof(EnumDisplayWrapper.Value),