// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Collections.Generic; using System.Linq; using Core.Common.Base; using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.Forms.PresentationObjects { /// /// 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 : ObservableWrappedObjectContextBase where T : IObservable { /// /// Initializes a new instance of the class. /// /// The concrete data instance wrapped by this context object. /// The surface lines available within the piping context. /// The stochastic soil models available within the piping context. /// The piping failure mechanism which the piping context belongs to. /// The assessment section which the piping context belongs to. /// Thrown when any input argument is null. protected PipingContext( T wrappedData, IEnumerable surfaceLines, IEnumerable stochasticSoilModels, MacroStabilityInwardsFailureMechanism macroStabilityInwardsFailureMechanism, IAssessmentSection assessmentSection) : base(wrappedData) { AssertInputsAreNotNull(surfaceLines, stochasticSoilModels, macroStabilityInwardsFailureMechanism, assessmentSection); AvailablePipingSurfaceLines = surfaceLines; AvailableStochasticSoilModels = stochasticSoilModels; FailureMechanism = macroStabilityInwardsFailureMechanism; AssessmentSection = assessmentSection; } /// /// Gets the available piping surface lines in order for the user to select one to /// set . /// public IEnumerable AvailablePipingSurfaceLines { get; private set; } /// /// Gets the available stochastic soil models in order for the user to select a and /// to set and . /// public IEnumerable AvailableStochasticSoilModels { get; private set; } /// /// Gets the available hydraulic boundary locations in order for the user to select one to /// set . /// public IEnumerable AvailableHydraulicBoundaryLocations { get { if (AssessmentSection.HydraulicBoundaryDatabase == null) { return Enumerable.Empty(); } return AssessmentSection.HydraulicBoundaryDatabase.Locations; } } /// /// Gets the piping failure mechanism which the piping context belongs to. /// public MacroStabilityInwardsFailureMechanism FailureMechanism { get; } /// /// Gets the assessment section which the piping context belongs to. /// public IAssessmentSection AssessmentSection { get; } /// /// Asserts the inputs are not null. /// /// The surface lines. /// The stochastic soil models. /// The macro stability inwards failure mechanism. /// The assessment section. /// Thrown when any input parameter is null. private static void AssertInputsAreNotNull(object surfaceLines, object stochasticSoilModels, object macroStabilityInwardsFailureMechanism, object assessmentSection) { if (surfaceLines == null) { throw new ArgumentNullException(nameof(surfaceLines)); } if (stochasticSoilModels == null) { throw new ArgumentNullException(nameof(stochasticSoilModels)); } if (macroStabilityInwardsFailureMechanism == null) { throw new ArgumentNullException(nameof(macroStabilityInwardsFailureMechanism)); } if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } } } }