Exemplo n.º 1
0
        /// <summary>
        /// Creates an instance of <see cref="SerializableFailureMechanismSection"/> based on
        /// its input parameters.
        /// </summary>
        /// <param name="idGenerator">The id generator to generate an id
        /// for <see cref="SerializableFailureMechanismSection"/>.</param>
        /// <param name="serializableCollection">The <see cref="SerializableFailureMechanismSectionCollection"/>
        /// this section belongs to.</param>
        /// <param name="section">The <see cref="ExportableCombinedFailureMechanismSection"/>
        /// to create a <see cref="SerializableFailureMechanismSection"/> for.</param>
        /// <returns>A <see cref="SerializableFailureMechanismSection"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static SerializableFailureMechanismSection Create(IdentifierGenerator idGenerator,
                                                                 SerializableFailureMechanismSectionCollection serializableCollection,
                                                                 ExportableCombinedFailureMechanismSection section)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException(nameof(idGenerator));
            }

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

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

            return(new SerializableFailureMechanismSection(idGenerator.GetNewId(Resources.SerializableFailureMechanismSection_IdPrefix),
                                                           serializableCollection,
                                                           section.StartDistance,
                                                           section.EndDistance,
                                                           section.Geometry,
                                                           SerializableFailureMechanismSectionType.Combined,
                                                           SerializableAssemblyMethodCreator.Create(section.AssemblyMethod)));
        }
        /// <summary>
        /// Creates an instance of <see cref="SerializableFailureMechanismAssemblyResult"/>
        /// based on <paramref name="result"/>.
        /// </summary>
        /// <param name="result">The <see cref="ExportableFailureMechanismAssemblyResult"/>
        /// to create a <see cref="SerializableFailureMechanismAssemblyResult"/> for.</param>
        /// <returns>A <see cref="SerializableFailureMechanismAssemblyResult"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="result"/>
        /// is <c>null</c>.</exception>>
        public static SerializableFailureMechanismAssemblyResult Create(ExportableFailureMechanismAssemblyResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            return(new SerializableFailureMechanismAssemblyResult(
                       result.Probability, SerializableAssemblyMethodCreator.Create(result.AssemblyMethod)));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates an instance of <see cref="SerializableAssembly"/> based
        /// on <paramref name="assessmentSection"/>.
        /// </summary>
        /// <param name="assessmentSection">The <see cref="ExportableAssessmentSection"/>
        /// to create a <see cref="SerializableAssembly"/> for.</param>
        /// <returns>A <see cref="SerializableAssembly"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="assessmentSection"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="AssemblyCreatorException">Thrown when the <paramref name="assessmentSection"/> is invalid
        /// to create a serializable counterpart for.</exception>
        public static SerializableAssembly Create(ExportableAssessmentSection assessmentSection)
        {
            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            var    idGenerator            = new IdentifierGenerator();
            string serializableAssemblyId = idGenerator.GetNewId(Resources.SerializableAssembly_IdPrefix);

            SerializableAssessmentSection   serializableAssessmentSection   = SerializableAssessmentSectionCreator.Create(assessmentSection);
            SerializableAssessmentProcess   serializableAssessmentProcess   = SerializableAssessmentProcessCreator.Create(idGenerator, serializableAssessmentSection);
            SerializableTotalAssemblyResult serializableTotalAssemblyResult =
                SerializableTotalAssemblyResultCreator.Create(
                    idGenerator,
                    serializableAssessmentProcess,
                    SerializableAssemblyMethodCreator.Create(assessmentSection.AssessmentSectionAssembly.ProbabilityAssemblyMethod),
                    SerializableAssemblyMethodCreator.Create(assessmentSection.AssessmentSectionAssembly.AssemblyGroupAssemblyMethod),
                    SerializableAssessmentSectionAssemblyGroupCreator.Create(assessmentSection.AssessmentSectionAssembly.AssemblyGroup),
                    assessmentSection.AssessmentSectionAssembly.Probability);

            AggregatedSerializableFailureMechanism[] aggregatedFailureMechanisms = assessmentSection.FailureMechanisms
                                                                                   .Select(fm => AggregatedSerializableFailureMechanismCreator.Create(
                                                                                               idGenerator, serializableTotalAssemblyResult, fm))
                                                                                   .ToArray();

            AggregatedSerializableCombinedFailureMechanismSectionAssemblies aggregatedSerializableCombinedFailureMechanismSectionAssemblies =
                AggregatedSerializableCombinedFailureMechanismSectionAssembliesCreator.Create(
                    idGenerator, serializableTotalAssemblyResult, assessmentSection.CombinedSectionAssemblies);

            return(new SerializableAssembly(
                       serializableAssemblyId,
                       GetLowerCorner(assessmentSection.Geometry),
                       GetUpperCorner(assessmentSection.Geometry),
                       serializableAssessmentSection,
                       serializableAssessmentProcess,
                       serializableTotalAssemblyResult,
                       aggregatedFailureMechanisms.Select(afm => afm.FailureMechanism),
                       aggregatedFailureMechanisms.SelectMany(afm => afm.FailureMechanismSectionAssemblyResults),
                       aggregatedSerializableCombinedFailureMechanismSectionAssemblies.CombinedFailureMechanismSectionAssemblies,
                       GetAllSerializableFailureMechanismSectionCollections(
                           aggregatedFailureMechanisms, aggregatedSerializableCombinedFailureMechanismSectionAssemblies),
                       aggregatedFailureMechanisms.SelectMany(afm => afm.FailureMechanismSections)
                       .Concat(aggregatedSerializableCombinedFailureMechanismSectionAssemblies.FailureMechanismSections)));
        }
Exemplo n.º 5
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)));
        }