// 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.Xml.Serialization; using Riskeer.AssemblyTool.IO.Model.DataTypes; using Riskeer.AssemblyTool.IO.Model.Enums; using Riskeer.AssemblyTool.IO.Model.Helpers; using Riskeer.AssemblyTool.IO.Properties; namespace Riskeer.AssemblyTool.IO.Model { /// /// Class describing a serializable failure mechanism. /// [XmlType(AssemblyXmlIdentifiers.FailureMechanism)] public class SerializableFailureMechanism : SerializableFeatureMember { /// /// Creates a new instance of . /// public SerializableFailureMechanism() { DirectFailureMechanism = Resources.DirectFailureMechanism; } /// /// Creates a new instance of . /// /// The unique ID of the assembly result. /// The total assembly result the failure mechanism belongs to. /// The type of the failure mechanism. /// The group of the failure mechanism. /// The total failure mechanism assembly result. /// Thrown when any parameter except is null. /// Thrown when is invalid. public SerializableFailureMechanism(string id, SerializableTotalAssemblyResult totalAssemblyResult, SerializableFailureMechanismType failureMechanismType, SerializableFailureMechanismGroup failureMechanismGroup, SerializableFailureMechanismAssemblyResult failureMechanismAssemblyResult) : this() { if (!SerializableIdValidator.Validate(id)) { throw new ArgumentException($@"'{nameof(id)}' must have a value and consist only of alphanumerical characters, '-', '_' or '.'."); } if (totalAssemblyResult == null) { throw new ArgumentNullException(nameof(totalAssemblyResult)); } if (failureMechanismAssemblyResult == null) { throw new ArgumentNullException(nameof(failureMechanismAssemblyResult)); } Id = id; TotalAssemblyResultId = totalAssemblyResult.Id; FailureMechanismType = failureMechanismType; FailureMechanismGroup = failureMechanismGroup; FailureMechanismAssemblyResult = failureMechanismAssemblyResult; } /// /// Gets or sets the ID. /// [XmlAttribute(AssemblyXmlIdentifiers.FailureMechanismId)] public string Id { get; set; } /// /// Gets or sets the parent total assembly result ID. /// [XmlAttribute(AssemblyXmlIdentifiers.TotalAssemblyResultIdRef)] public string TotalAssemblyResultId { get; set; } /// /// Gets or sets the failure mechanism type. /// [XmlElement(AssemblyXmlIdentifiers.FailureMechanismType)] public SerializableFailureMechanismType FailureMechanismType { get; set; } /// /// Gets or sets the failure mechanism group. /// [XmlElement(AssemblyXmlIdentifiers.FailureMechanismGroup)] public SerializableFailureMechanismGroup FailureMechanismGroup { get; set; } /// /// Gets or sets the direct failure mechanism indicator. /// [XmlElement(AssemblyXmlIdentifiers.DirectFailureMechanism)] public string DirectFailureMechanism { get; set; } /// /// Gets or sets the total failure mechanism assembly result. /// [XmlElement(AssemblyXmlIdentifiers.FailureMechanismAssemblyResult)] public SerializableFailureMechanismAssemblyResult FailureMechanismAssemblyResult { get; set; } } }