Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismContributionProperties.cs
===================================================================
diff -u -r8905298103eb01ce13dd5c1a2f267f879d4fda3e -r1b04d8b730017db5c2a205203432f0b13f8d4192
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismContributionProperties.cs (.../FailureMechanismContributionProperties.cs) (revision 8905298103eb01ce13dd5c1a2f267f879d4fda3e)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismContributionProperties.cs (.../FailureMechanismContributionProperties.cs) (revision 1b04d8b730017db5c2a205203432f0b13f8d4192)
@@ -27,11 +27,9 @@
using Core.Common.Gui.PropertyBag;
using Core.Common.Utils;
using Core.Common.Utils.Attributes;
-using Core.Common.Utils.Reflection;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Contribution;
using Ringtoets.Integration.Forms.Properties;
-using Ringtoets.Integration.Forms.Views;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.Integration.Forms.PropertyClasses
@@ -43,7 +41,44 @@
{
private IFailureMechanismContributionNormChangeHandler normChangeHandler;
private IAssessmentSectionCompositionChangeHandler compositionChangeHandler;
+ private IAssessmentSection assessmentSection;
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The for which the properties are shown.
+ /// The assessment section for which the properties are shown.
+ /// The for when the norm changes.
+ /// The for when the composition changes.
+ public FailureMechanismContributionProperties(
+ FailureMechanismContribution failureMechanismContribution,
+ IAssessmentSection assessmentSection,
+ IFailureMechanismContributionNormChangeHandler normChangeHandler,
+ IAssessmentSectionCompositionChangeHandler compositionChangeHandler)
+ {
+ if (failureMechanismContribution == null)
+ {
+ throw new ArgumentNullException("failureMechanismContribution");
+ }
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException("assessmentSection");
+ }
+ if (normChangeHandler == null)
+ {
+ throw new ArgumentNullException("normChangeHandler");
+ }
+ if (compositionChangeHandler == null)
+ {
+ throw new ArgumentNullException("compositionChangeHandler");
+ }
+
+ Data = failureMechanismContribution;
+ this.normChangeHandler = normChangeHandler;
+ this.compositionChangeHandler = compositionChangeHandler;
+ this.assessmentSection = assessmentSection;
+ }
+
[TypeConverter(typeof(EnumTypeConverter))]
[ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")]
[ResourcesDisplayName(typeof(Resources), "FailureMechanismContribution_Composition_DisplayName")]
@@ -52,13 +87,13 @@
{
get
{
- return AssessmentSection.Composition;
+ return assessmentSection.Composition;
}
set
{
if (compositionChangeHandler.ConfirmCompositionChange())
{
- IEnumerable changedObjects = compositionChangeHandler.ChangeComposition(AssessmentSection, value);
+ IEnumerable changedObjects = compositionChangeHandler.ChangeComposition(assessmentSection, value);
foreach (IObservable changedObject in changedObjects)
{
changedObject.NotifyObservers();
@@ -88,70 +123,13 @@
if (value != 0 && normChangeHandler.ConfirmNormChange())
{
double newNormValue = 1.0/Convert.ToInt32(value);
- IEnumerable changedObjects = normChangeHandler.ChangeNorm(AssessmentSection, newNormValue);
+ IEnumerable changedObjects = normChangeHandler.ChangeNorm(assessmentSection, newNormValue);
foreach (IObservable changedObject in changedObjects)
{
changedObject.NotifyObservers();
}
}
}
}
-
- ///
- /// Gets or sets the assessment section this property control belongs to.
- ///
- [DynamicVisible]
- public IAssessmentSection AssessmentSection { get; set; }
-
- ///
- /// Gets or sets the for when the norm changes.
- ///
- /// Thrown when null is set.
- [DynamicVisible]
- public IFailureMechanismContributionNormChangeHandler NormChangeHandler
- {
- get
- {
- return normChangeHandler;
- }
- set
- {
- if (value == null)
- {
- throw new ArgumentNullException("value", @"NormChangeHandler is null");
- }
- normChangeHandler = value;
- }
- }
-
- ///
- /// Gets or sets the for when the norm changes.
- ///
- /// Thrown when null is set.
- [DynamicVisible]
- public IAssessmentSectionCompositionChangeHandler CompositionChangeHandler
- {
- get
- {
- return compositionChangeHandler;
- }
- set
- {
- if (value == null)
- {
- throw new ArgumentNullException("value", @"CompositionChangeHandler is null");
- }
- compositionChangeHandler = value;
- }
- }
-
- [DynamicVisibleValidationMethod]
- public bool DynamicVisibleValidationMethod(string propertyName)
- {
- // Hide all the properties that are used to set the data
- return propertyName != TypeUtils.GetMemberName(p => p.AssessmentSection)
- && propertyName != TypeUtils.GetMemberName(p => p.NormChangeHandler)
- && propertyName != TypeUtils.GetMemberName(p => p.CompositionChangeHandler);
- }
}
}
\ No newline at end of file