Esempio n. 1
0
        /// <summary>
        /// Creates a collection of <see cref="ExportableCombinedSectionAssembly"/>
        /// based on <paramref name="combinedSectionAssemblyResults"/>.
        /// </summary>
        /// <param name="combinedSectionAssemblyResults">A collection of combined section results to
        /// create a collection of <see cref="ExportableCombinedSectionAssembly"/> for.</param>
        /// <param name="assessmentSection">The <see cref="AssessmentSection"/> the section results belong to.</param>
        /// <returns>A collection of <see cref="ExportableCombinedSectionAssembly"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static IEnumerable <ExportableCombinedSectionAssembly> CreateExportableCombinedSectionAssemblyCollection(
            IEnumerable <CombinedFailureMechanismSectionAssemblyResult> combinedSectionAssemblyResults,
            AssessmentSection assessmentSection)
        {
            if (combinedSectionAssemblyResults == null)
            {
                throw new ArgumentNullException(nameof(combinedSectionAssemblyResults));
            }

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

            var sectionResults = new List <ExportableCombinedSectionAssembly>();

            foreach (CombinedFailureMechanismSectionAssemblyResult assemblyResult in combinedSectionAssemblyResults)
            {
                var exportableSection = new ExportableCombinedFailureMechanismSection(
                    FailureMechanismSectionHelper.GetFailureMechanismSectionGeometry(
                        assessmentSection.ReferenceLine, assemblyResult.SectionStart, assemblyResult.SectionEnd),
                    assemblyResult.SectionStart,
                    assemblyResult.SectionEnd,
                    ExportableAssemblyMethodFactory.Create(assemblyResult.CommonSectionAssemblyMethod));

                var exportableSectionResult = new ExportableCombinedSectionAssembly(
                    exportableSection, new ExportableFailureMechanismSectionAssemblyResult(
                        exportableSection, assemblyResult.TotalResult, ExportableAssemblyMethodFactory.Create(assemblyResult.CombinedSectionResultAssemblyMethod)),
                    CreateFailureMechanismCombinedSectionAssemblyResults(assemblyResult, assessmentSection));

                sectionResults.Add(exportableSectionResult);
            }

            return(sectionResults);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a collection of <see cref="ExportableFailureMechanismSectionAssemblyWithProbabilityResult"/>
        /// with assembly results based on <paramref name="failureMechanism"/>.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism to create a collection of
        /// <see cref="ExportableFailureMechanismSectionAssemblyWithProbabilityResult"/> for.</param>
        /// <param name="assessmentSection">The <see cref="IAssessmentSection"/> to use in the assembly.</param>
        /// <param name="assembleFailureMechanismSectionFunc">The <see cref="Func{T1,T2,T3,TResult}"/>
        /// to perform the failure mechanism section assembly.</param>
        /// <typeparam name="TFailureMechanism">The type of the failure mechanism.</typeparam>
        /// <typeparam name="TSectionResult">The type of the section result.</typeparam>
        /// <returns>A collection of <see cref="ExportableFailureMechanismSectionAssemblyWithProbabilityResult"/>.</returns>
        /// <exception cref="AssemblyException">Thrown when assembly results cannot be created.</exception>
        private static IEnumerable <ExportableFailureMechanismSectionAssemblyWithProbabilityResult> CreateExportableFailureMechanismSectionResults
        <TFailureMechanism, TSectionResult>(
            TFailureMechanism failureMechanism, IAssessmentSection assessmentSection,
            Func <TSectionResult, TFailureMechanism, IAssessmentSection, FailureMechanismSectionAssemblyResultWrapper> assembleFailureMechanismSectionFunc)
            where TFailureMechanism : IFailureMechanism <TSectionResult>
            where TSectionResult : FailureMechanismSectionResult
        {
            IDictionary <TSectionResult, ExportableFailureMechanismSection> failureMechanismSectionsLookup =
                ExportableFailureMechanismSectionHelper.CreateFailureMechanismSectionResultLookup(failureMechanism.SectionResults);

            var exportableResults = new List <ExportableFailureMechanismSectionAssemblyWithProbabilityResult>();

            foreach (KeyValuePair <TSectionResult, ExportableFailureMechanismSection> failureMechanismSectionPair in failureMechanismSectionsLookup)
            {
                FailureMechanismSectionAssemblyResultWrapper assemblyResultWrapper = assembleFailureMechanismSectionFunc(
                    failureMechanismSectionPair.Key, failureMechanism, assessmentSection);
                FailureMechanismSectionAssemblyResult assemblyResult = assemblyResultWrapper.AssemblyResult;

                exportableResults.Add(
                    new ExportableFailureMechanismSectionAssemblyWithProbabilityResult(
                        failureMechanismSectionPair.Value, assemblyResult.FailureMechanismSectionAssemblyGroup, assemblyResult.SectionProbability,
                        ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyGroupMethod),
                        ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.ProbabilityMethod)));
            }

            return(exportableResults);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates an <see cref="ExportableAssessmentSectionAssemblyResult"/> with the assembly result
        /// based on <paramref name="assessmentSection"/>.
        /// </summary>
        /// <param name="assessmentSection">The assessment section to create an <see cref="ExportableAssessmentSectionAssemblyResult"/> for.</param>
        /// <returns>An <see cref="ExportableAssessmentSectionAssemblyResult"/> with assembly result.</returns>
        /// <exception cref="AssemblyException">Thrown when assembly result cannot be created for <paramref name="assessmentSection"/>.</exception>
        private static ExportableAssessmentSectionAssemblyResult CreateExportableAssessmentSectionAssemblyResult(AssessmentSection assessmentSection)
        {
            AssessmentSectionAssemblyResultWrapper assemblyResultWrapper = AssessmentSectionAssemblyFactory.AssembleAssessmentSection(assessmentSection);
            AssessmentSectionAssemblyResult        assemblyResult        = assemblyResultWrapper.AssemblyResult;

            return(new ExportableAssessmentSectionAssemblyResult(
                       assemblyResult.AssemblyGroup, assemblyResult.Probability,
                       ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyGroupMethod),
                       ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.ProbabilityMethod)));
        }
Esempio n. 4
0
        /// <summary>
        /// Creates an <see cref="ExportableFailureMechanism"/>
        /// with assembly results based on the input parameters.
        /// </summary>
        /// <param name="failureMechanism">The failure mechanism to create an <see cref="ExportableFailureMechanism"/> for.</param>
        /// <param name="assessmentSection">The assessment section the failure mechanism belongs to.</param>
        /// <param name="assembleFailureMechanismFunc">The <see cref="Func{T1,T2,TResult}"/> to perform
        /// the failure mechanism assembly.</param>
        /// <param name="assembleFailureMechanismSectionFunc">The <see cref="Func{T1,T2,T3,TResult}"/>
        /// to perform the failure mechanism section assembly.</param>
        /// <param name="failureMechanismType">The type of the failure mechanism.</param>
        /// <typeparam name="TFailureMechanism">The type of the failure mechanism.</typeparam>
        /// <typeparam name="TSectionResult">The type of the section result.</typeparam>
        /// <returns>An <see cref="ExportableFailureMechanism"/> with assembly results.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="failureMechanism"/>,
        /// <paramref name="assessmentSection"/>, <paramref name="assembleFailureMechanismFunc"/> or
        /// <paramref name="assembleFailureMechanismSectionFunc"/> is <c>null</c>.</exception>
        /// <exception cref="AssemblyException">Thrown when assembly results cannot be created.</exception>
        public static ExportableFailureMechanism CreateExportableFailureMechanism <TFailureMechanism, TSectionResult>(
            TFailureMechanism failureMechanism, IAssessmentSection assessmentSection,
            Func <TFailureMechanism, IAssessmentSection, FailureMechanismAssemblyResultWrapper> assembleFailureMechanismFunc,
            Func <TSectionResult, TFailureMechanism, IAssessmentSection, FailureMechanismSectionAssemblyResultWrapper> assembleFailureMechanismSectionFunc,
            ExportableFailureMechanismType failureMechanismType)
            where TFailureMechanism : IFailureMechanism <TSectionResult>
            where TSectionResult : FailureMechanismSectionResult
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

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

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

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

            FailureMechanismAssemblyResultWrapper assemblyResultWrapper = assembleFailureMechanismFunc(failureMechanism, assessmentSection);

            return(new ExportableFailureMechanism(
                       new ExportableFailureMechanismAssemblyResult(
                           assemblyResultWrapper.AssemblyResult,
                           ExportableAssemblyMethodFactory.Create(assemblyResultWrapper.AssemblyMethod)),
                       CreateExportableFailureMechanismSectionResults(
                           failureMechanism, assessmentSection, assembleFailureMechanismSectionFunc),
                       failureMechanismType, failureMechanism.Code, failureMechanism.Name));
        }
Esempio n. 5
0
 private static ExportableFailureMechanismCombinedSectionAssemblyResult CreateExportableFailureMechanismCombinedSectionAssemblyResult(
     FailureMechanismSectionAssemblyGroup sectionAssemblyGroup, AssemblyMethod assemblyMethod,
     ExportableFailureMechanismType failureMechanismType, string failureMechanismCode, string failureMechanismName)
 {
     return(new ExportableFailureMechanismCombinedSectionAssemblyResult(
                new ExportableFailureMechanismSubSectionAssemblyResult(sectionAssemblyGroup, ExportableAssemblyMethodFactory.Create(assemblyMethod)),
                failureMechanismType, failureMechanismCode, failureMechanismName));
 }