Example #1
0
        /// <summary>
        /// Creates an instance of <see cref="SerializableFailureMechanismSectionAssemblyResult"/>
        /// based on its input parameters.
        /// </summary>
        /// <param name="sectionResult">The <see cref="ExportableFailureMechanismSectionAssemblyWithProbabilityResult"/> to create a
        /// <see cref="SerializableFailureMechanismSectionAssemblyResult"/> for.</param>
        /// <returns>A <see cref="SerializableFailureMechanismSectionAssemblyResult"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="sectionResult"/> is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="sectionResult"/> is invalid to
        /// create a serializable counterpart for.</exception>
        public static SerializableFailureMechanismSectionAssemblyResult Create(ExportableFailureMechanismSectionAssemblyWithProbabilityResult sectionResult)
        {
            if (sectionResult == null)
            {
                throw new ArgumentNullException(nameof(sectionResult));
            }

            ValidateAssemblyResult(sectionResult);

            return(new SerializableFailureMechanismSectionAssemblyResult(
                       SerializableAssemblyMethodCreator.Create(sectionResult.ProbabilityAssemblyMethod),
                       SerializableAssemblyMethodCreator.Create(sectionResult.AssemblyGroupAssemblyMethod),
                       SerializableFailureMechanismSectionAssemblyGroupCreator.Create(sectionResult.AssemblyGroup),
                       sectionResult.Probability));
        }
Example #2
0
        /// <summary>
        /// Creates an instance of <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssembly"/>
        /// based on its input parameters.
        /// </summary>
        /// <param name="idGenerator">The generator to generate ids for the serializable components.</param>
        /// <param name="serializableTotalAssemblyResult">The <see cref="SerializableTotalAssemblyResult"/> the serializable
        /// components belongs to.</param>
        /// <param name="serializableFailureMechanismSectionCollection">The <see cref="SerializableFailureMechanismSectionCollection"/>
        /// the serializable failure mechanism sections belong to.</param>
        /// <param name="combinedSectionAssembly">The <see cref="ExportableCombinedSectionAssembly"/> to create an
        /// <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssembly"/> for.</param>
        /// <returns>An <see cref="AggregatedSerializableCombinedFailureMechanismSectionAssembly"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="combinedSectionAssembly"/>
        /// is invalid to create a serializable counterpart for.</exception>
        public static AggregatedSerializableCombinedFailureMechanismSectionAssembly Create(IdentifierGenerator idGenerator,
                                                                                           SerializableTotalAssemblyResult serializableTotalAssemblyResult,
                                                                                           SerializableFailureMechanismSectionCollection serializableFailureMechanismSectionCollection,
                                                                                           ExportableCombinedSectionAssembly combinedSectionAssembly)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException(nameof(idGenerator));
            }

            if (serializableTotalAssemblyResult == null)
            {
                throw new ArgumentNullException(nameof(serializableTotalAssemblyResult));
            }

            if (serializableFailureMechanismSectionCollection == null)
            {
                throw new ArgumentNullException(nameof(serializableFailureMechanismSectionCollection));
            }

            if (combinedSectionAssembly == null)
            {
                throw new ArgumentNullException(nameof(combinedSectionAssembly));
            }

            SerializableFailureMechanismSection failureMechanismSection = SerializableFailureMechanismSectionCreator.Create(
                idGenerator, serializableFailureMechanismSectionCollection, combinedSectionAssembly.Section);

            return(new AggregatedSerializableCombinedFailureMechanismSectionAssembly(
                       failureMechanismSection,
                       new SerializableCombinedFailureMechanismSectionAssembly(
                           idGenerator.GetNewId(Resources.SerializableCombinedFailureMechanismSectionAssembly_IdPrefix),
                           serializableTotalAssemblyResult,
                           failureMechanismSection,
                           combinedSectionAssembly.FailureMechanismResults
                           .Select(SerializableCombinedFailureMechanismSectionAssemblyResultCreator.Create)
                           .ToArray(),
                           new SerializableFailureMechanismSubSectionAssemblyResult(
                               SerializableAssemblyMethod.BOI3C1,
                               SerializableFailureMechanismSectionAssemblyGroupCreator.Create(
                                   combinedSectionAssembly.CombinedSectionAssemblyResult.AssemblyGroup)))));
        }
Example #3
0
        /// <summary>
        /// Creates an instance of <see cref="SerializableCombinedFailureMechanismSectionAssemblyResult"/>
        /// based on <paramref name="sectionResult"/>.
        /// </summary>
        /// <param name="sectionResult">The <see cref="ExportableFailureMechanismCombinedSectionAssemblyResult"/>
        /// to create a <see cref="SerializableCombinedFailureMechanismSectionAssemblyResult"/> for.</param>
        /// <returns>A <see cref="SerializableCombinedFailureMechanismSectionAssemblyResult"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="sectionResult"/> is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when <paramref name="sectionResult"/>
        /// is invalid to create a serializable counterpart for.</exception>
        public static SerializableCombinedFailureMechanismSectionAssemblyResult Create(ExportableFailureMechanismCombinedSectionAssemblyResult sectionResult)
        {
            if (sectionResult == null)
            {
                throw new ArgumentNullException(nameof(sectionResult));
            }

            ExportableFailureMechanismSubSectionAssemblyResult sectionResultSectionAssemblyResult = sectionResult.SectionAssemblyResult;

            if (sectionResultSectionAssemblyResult.AssemblyGroup == FailureMechanismSectionAssemblyGroup.NoResult ||
                sectionResultSectionAssemblyResult.AssemblyGroup == FailureMechanismSectionAssemblyGroup.Dominant)
            {
                throw new AssemblyCreatorException("The assembly result is invalid and cannot be created.");
            }

            return(new SerializableCombinedFailureMechanismSectionAssemblyResult(
                       SerializableAssemblyMethodCreator.Create(sectionResultSectionAssemblyResult.AssemblyMethod),
                       SerializableFailureMechanismTypeCreator.Create(sectionResult.FailureMechanismType),
                       sectionResult.Code,
                       sectionResult.Name,
                       SerializableFailureMechanismSectionAssemblyGroupCreator.Create(sectionResultSectionAssemblyResult.AssemblyGroup)));
        }