// Copyright (C) Stichting Deltares 2018. 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.ComponentModel; using Assembly.Kernel.Exceptions; using Assembly.Kernel.Interfaces; using Assembly.Kernel.Model; using Riskeer.AssemblyTool.Data; namespace Riskeer.AssemblyTool.KernelWrapper.Creators { /// /// Creates input instances to be used in the . /// internal static class AssessmentSectionAssemblyInputCreator { /// /// Creates based on the given parameters. /// /// The assembly to create a for. /// The created . /// Thrown when /// is null. /// Thrown when contains /// an invalid . /// Thrown when contains /// a valid but unsupported . /// Thrown when has an /// invalid value. public static FailureMechanismAssemblyResult CreateFailureMechanismAssemblyResult(FailureMechanismAssembly input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } return new FailureMechanismAssemblyResult(CreateFailureMechanismCategory(input.Group), input.Probability); } /// /// Creates based on the given parameters. /// /// The assembly to create a for. /// The created . /// Thrown when contains /// an invalid . /// Thrown when contains /// a valid but unsupported . public static FailureMechanismAssemblyResult CreateFailureMechanismAssemblyResult(FailureMechanismAssemblyCategoryGroup input) { return new FailureMechanismAssemblyResult(CreateFailureMechanismCategory(input), double.NaN); } /// /// Creates a based on the . /// /// The /// to create a for. /// The created . /// Thrown when contains /// an invalid . /// Thrown when contains /// a valid but unsupported . public static EFailureMechanismCategory CreateFailureMechanismCategory(FailureMechanismAssemblyCategoryGroup input) { if (!Enum.IsDefined(typeof(FailureMechanismAssemblyCategoryGroup), input)) { throw new InvalidEnumArgumentException(nameof(input), (int) input, typeof(FailureMechanismAssemblyCategoryGroup)); } switch (input) { case FailureMechanismAssemblyCategoryGroup.None: return EFailureMechanismCategory.Gr; case FailureMechanismAssemblyCategoryGroup.NotApplicable: return EFailureMechanismCategory.Nvt; case FailureMechanismAssemblyCategoryGroup.It: return EFailureMechanismCategory.It; case FailureMechanismAssemblyCategoryGroup.IIt: return EFailureMechanismCategory.IIt; case FailureMechanismAssemblyCategoryGroup.IIIt: return EFailureMechanismCategory.IIIt; case FailureMechanismAssemblyCategoryGroup.IVt: return EFailureMechanismCategory.IVt; case FailureMechanismAssemblyCategoryGroup.Vt: return EFailureMechanismCategory.Vt; case FailureMechanismAssemblyCategoryGroup.VIt: return EFailureMechanismCategory.VIt; case FailureMechanismAssemblyCategoryGroup.VIIt: return EFailureMechanismCategory.VIIt; default: throw new NotSupportedException(); } } } }