Index: Core/Common/src/Core.Common.Controls/PresentationObjects/WrappedObjectContextBase.cs =================================================================== diff -u -r7710a5b982ae6a70d740a6d2af8200560ec37f68 -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d --- Core/Common/src/Core.Common.Controls/PresentationObjects/WrappedObjectContextBase.cs (.../WrappedObjectContextBase.cs) (revision 7710a5b982ae6a70d740a6d2af8200560ec37f68) +++ Core/Common/src/Core.Common.Controls/PresentationObjects/WrappedObjectContextBase.cs (.../WrappedObjectContextBase.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d) @@ -12,6 +12,11 @@ /// The object type of the wrapped instance. public abstract class WrappedObjectContextBase : IObservable, IEquatable> where T : IObservable { + /// + /// Initializes a new instance of the class. + /// + /// The wrapped data. + /// When is null. protected WrappedObjectContextBase(T wrappedData) { if (wrappedData == null) Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismContributionContext.cs =================================================================== diff -u -rf1bd17ba95b3fbae5928d4240523d50d8b83b64d -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismContributionContext.cs (.../FailureMechanismContributionContext.cs) (revision f1bd17ba95b3fbae5928d4240523d50d8b83b64d) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismContributionContext.cs (.../FailureMechanismContributionContext.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d) @@ -21,6 +21,8 @@ using System; using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; + using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Contribution; @@ -29,88 +31,33 @@ /// /// This class is a presentation object for a instance. /// - public sealed class FailureMechanismContributionContext : IEquatable, IObservable + public sealed class FailureMechanismContributionContext : WrappedObjectContextBase { /// /// Initializes a new instance of the class. /// /// The contribution. /// The parent of . + /// When any input argument is null. public FailureMechanismContributionContext(FailureMechanismContribution contribution, IAssessmentSection contributionOwner) + : base(contribution) { - AssertInputsAreNotNull(contribution, contributionOwner); + AssertInputsAreNotNull(contributionOwner); - WrappedData = contribution; Parent = contributionOwner; } /// - /// Gets the concrete data instance wrapped by this context object. + /// Gets the assessment section to which belongs to. /// - public FailureMechanismContribution WrappedData { get; private set; } - - /// - /// Gets the assessment section to which belongs to. - /// public IAssessmentSection Parent { get; private set; } - private void AssertInputsAreNotNull(FailureMechanismContribution contribution, IAssessmentSection contributionOwner) + private void AssertInputsAreNotNull(IAssessmentSection contributionOwner) { - if (contribution == null) - { - throw new ArgumentNullException("contribution", "Failure mechanism contribution cannot be null."); - } - if (contributionOwner == null) { throw new ArgumentNullException("contributionOwner", "Assessment section cannot be null."); } } - - #region IEquatable - - public bool Equals(FailureMechanismContributionContext other) - { - if (ReferenceEquals(null, other)) - { - return false; - } - if (ReferenceEquals(this, other)) - { - return true; - } - return WrappedData.Equals(other.WrappedData); - } - - public override bool Equals(object obj) - { - return Equals(obj as FailureMechanismContributionContext); - } - - public override int GetHashCode() - { - return WrappedData.GetHashCode(); - } - - #endregion - - #region IObservable - - public void Attach(IObserver observer) - { - WrappedData.Attach(observer); - } - - public void Detach(IObserver observer) - { - WrappedData.Detach(observer); - } - - public void NotifyObservers() - { - WrappedData.NotifyObservers(); - } - - #endregion } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionsContext.cs =================================================================== diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionsContext.cs (.../FailureMechanismSectionsContext.cs) (revision a9aafffab97152303562110b1d789bacb465ce24) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PresentationObjects/FailureMechanismSectionsContext.cs (.../FailureMechanismSectionsContext.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d) @@ -24,7 +24,6 @@ using Core.Common.Base; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismContributionContextTest.cs =================================================================== diff -u -rf1bd17ba95b3fbae5928d4240523d50d8b83b64d -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismContributionContextTest.cs (.../FailureMechanismContributionContextTest.cs) (revision f1bd17ba95b3fbae5928d4240523d50d8b83b64d) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PresentationObjects/FailureMechanismContributionContextTest.cs (.../FailureMechanismContributionContextTest.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d) @@ -22,6 +22,7 @@ using System; using System.Linq; using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; @@ -50,7 +51,7 @@ var context = new FailureMechanismContributionContext(contribution, assessmentSection); // Assert - Assert.IsInstanceOf>(context); + Assert.IsInstanceOf>>(context); Assert.IsInstanceOf(context); Assert.AreSame(contribution, context.WrappedData); Assert.AreSame(assessmentSection, context.Parent); @@ -69,7 +70,7 @@ TestDelegate call = () => new FailureMechanismContributionContext(null, assessmentSection); // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Failure mechanism contribution cannot be null."); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Wrapped data of context cannot be null."); mocks.VerifyAll(); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs =================================================================== diff -u -r0faea705e7f83205f8420c52edda8a5473485bcd -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs (.../PipingContext.cs) (revision 0faea705e7f83205f8420c52edda8a5473485bcd) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingContext.cs (.../PipingContext.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d) @@ -23,6 +23,8 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base; +using Core.Common.Controls.PresentationObjects; + using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.HydraRing.Data; using Ringtoets.Piping.Data; @@ -35,7 +37,7 @@ /// Presentation object representing all required piping knowledge to configure and create /// piping related objects. It'll delegate observable behavior to the wrapped data object. /// - public abstract class PipingContext : IObservable where T : IObservable + public abstract class PipingContext : WrappedObjectContextBase where T : IObservable { /// /// Initializes a new instance of the class. @@ -49,11 +51,10 @@ T wrappedData, IEnumerable surfaceLines, IEnumerable stochasticSoilModels, - IAssessmentSection assessmentSection) + IAssessmentSection assessmentSection) : base(wrappedData) { - AssertInputsAreNotNull(wrappedData, surfaceLines, stochasticSoilModels, assessmentSection); + AssertInputsAreNotNull(surfaceLines, stochasticSoilModels, assessmentSection); - WrappedData = wrappedData; AvailablePipingSurfaceLines = surfaceLines; AvailableStochasticSoilModels = stochasticSoilModels; AssessmentSection = assessmentSection; @@ -88,46 +89,19 @@ } /// - /// Gets the concrete data instance wrapped by this context object. - /// - public T WrappedData { get; private set; } - - /// /// Gets the assessment section which the piping context belongs to. /// public IAssessmentSection AssessmentSection { get; private set; } - public override bool Equals(object obj) - { - var context = obj as PipingContext; - if (context != null) - { - return WrappedData.Equals(context.WrappedData); - } - return base.Equals(obj); - } - - public override int GetHashCode() - { - return WrappedData.GetHashCode(); - } - /// /// Asserts the inputs are not null. /// - /// The wrapped data. /// The surface lines. /// The soil profiles. /// The assessment section. /// When any input parameter is null. - private static void AssertInputsAreNotNull(object wrappedData, object surfaceLines, object soilProfiles, object assessmentSection) + private static void AssertInputsAreNotNull(object surfaceLines, object soilProfiles, object assessmentSection) { - if (wrappedData == null) - { - var message = String.Format(Resources.PipingContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null, - Resources.PipingContext_DataDescription_WrappedData); - throw new ArgumentNullException("wrappedData", message); - } if (surfaceLines == null) { var message = String.Format(Resources.PipingContext_AssertInputsAreNotNull_DataDescription_0_cannot_be_null, @@ -147,24 +121,5 @@ throw new ArgumentNullException("assessmentSection", message); } } - - #region IObservable - - public void Attach(IObserver observer) - { - WrappedData.Attach(observer); - } - - public void Detach(IObserver observer) - { - WrappedData.Detach(observer); - } - - public void NotifyObservers() - { - WrappedData.NotifyObservers(); - } - - #endregion } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs =================================================================== diff -u -r614c1aa4bf54ed2852d93a58ba8d49b549d5f46c -r59fccb6e0e34d12c43db9b9ea467b14396d78f5d --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs (.../PipingContextTest.cs) (revision 614c1aa4bf54ed2852d93a58ba8d49b549d5f46c) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PresentationObjects/PipingContextTest.cs (.../PipingContextTest.cs) (revision 59fccb6e0e34d12c43db9b9ea467b14396d78f5d) @@ -91,7 +91,7 @@ { Environment.NewLine }, StringSplitOptions.None)[0]; - Assert.AreEqual("Het piping data object mag niet 'null' zijn.", customMessage); + Assert.AreEqual("Wrapped data of context cannot be null.", customMessage); mocks.VerifyAll(); }