// Copyright (C) Stichting Deltares 2016. 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 Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Properties; namespace Ringtoets.Common.Data.Contribution { /// /// This class represents an amount for which a will /// contribute to the overall verdict of an assessment section. /// public class FailureMechanismContributionItem { private readonly IFailureMechanism failureMechanism; /// /// Creates a new instance of . With /// , and set. /// /// The for which the contribution is defined. /// The norm used to calculate the probability space. /// Gets a value indicating whether /// the corresponding failure mechanism is always relevant. When true, then /// cannot be set to false. /// Thrown when is null. public FailureMechanismContributionItem(IFailureMechanism failureMechanism, double norm, bool isFailureMechanismAlwaysRelevant = false) { if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism), Resources.FailureMechanismContributionItem_Can_not_create_contribution_item_without_failure_mechanism); } this.failureMechanism = failureMechanism; Norm = norm; IsAlwaysRelevant = isFailureMechanismAlwaysRelevant; } /// /// Gets the name of the assessment for which to configure the . /// public string Assessment { get { return failureMechanism.Name; } } /// /// Returns the code of the assessment for which to configure the /// public string AssessmentCode { get { return failureMechanism.Code; } } /// /// Gets the amount of contribution as a percentage. /// public double Contribution { get { return failureMechanism.Contribution; } } /// /// Gets or sets the norm of the complete assessment section. /// public double Norm { get; internal set; } /// /// Gets the probability space per year for the . /// public double ProbabilitySpace { get { return 100.0/(Norm*Contribution); } } /// /// Gets or sets a value indicating whether the corresponding failure mechanism is /// relevant or not. /// public bool IsRelevant { get { return IsAlwaysRelevant || failureMechanism.IsRelevant; } set { if (!IsAlwaysRelevant) { failureMechanism.IsRelevant = value; } } } /// /// Gets a value indicating whether the corresponding /// is always relevant. When true, then cannot be set to false. /// public bool IsAlwaysRelevant { get; private set; } /// /// Gets the failure mechanism. /// public IFailureMechanism FailureMechanism { get { return failureMechanism; } } /// /// Notifies the observers for the wrapped . /// public void NotifyFailureMechanismObservers() { failureMechanism.NotifyObservers(); } } }