Index: Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs =================================================================== diff -u -r64fc75f87a85b4f20e9c5a8438cee659371d1efd -r16fa5dc02d11ca5dad8bb4dbc5c7706b1286fff7 --- Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 64fc75f87a85b4f20e9c5a8438cee659371d1efd) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Factories/ExportableAssessmentSectionFactory.cs (.../ExportableAssessmentSectionFactory.cs) (revision 16fa5dc02d11ca5dad8bb4dbc5c7706b1286fff7) @@ -79,19 +79,19 @@ throw new ArgumentNullException(nameof(assessmentSection)); } - IEnumerable combinedSectionAssemblyResults = - AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection) - .ToArray(); - var registry = new ExportableModelRegistry(); + + List failureMechanismSectionCollections = CreateExportableFailureMechanismSectionCollections( + idGenerator, registry, assessmentSection); + return new ExportableAssessmentSection( IdentifierGenerator.GenerateId(Resources.ExportableAssessmentSection_IdPrefix, assessmentSection.Id), assessmentSection.Name, assessmentSection.ReferenceLine.Points, - CreateExportableFailureMechanismSectionCollections(idGenerator, registry, assessmentSection, combinedSectionAssemblyResults), + failureMechanismSectionCollections, CreateExportableAssessmentSectionAssemblyResult(idGenerator, assessmentSection), CreateExportableFailureMechanisms(idGenerator, registry, assessmentSection), - CreateExportableCombinedSectionAssemblyCollection(idGenerator, registry, assessmentSection, combinedSectionAssemblyResults)); + CreateExportableCombinedSectionAssemblyCollection(idGenerator, registry, assessmentSection, failureMechanismSectionCollections)); } /// @@ -287,25 +287,15 @@ } } - private static IEnumerable CreateExportableFailureMechanismSectionCollections( - IdentifierGenerator idGenerator, ExportableModelRegistry registry, IAssessmentSection assessmentSection, - IEnumerable combinedSectionAssemblyResults) + private static List CreateExportableFailureMechanismSectionCollections( + IdentifierGenerator idGenerator, ExportableModelRegistry registry, IAssessmentSection assessmentSection) { - List failureMechanismSectionCollections = - assessmentSection.GetFailureMechanisms() - .Concat(assessmentSection.SpecificFailureMechanisms) - .Where(fm => fm.InAssembly) - .Select(failureMechanism => ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( - idGenerator, registry, failureMechanism.Sections)) - .ToList(); - - if (combinedSectionAssemblyResults.Any()) - { - failureMechanismSectionCollections.Add(ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( - idGenerator, registry, assessmentSection.ReferenceLine, combinedSectionAssemblyResults)); - } - - return failureMechanismSectionCollections; + return assessmentSection.GetFailureMechanisms() + .Concat(assessmentSection.SpecificFailureMechanisms) + .Where(fm => fm.InAssembly) + .Select(fm => ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( + idGenerator, registry, fm.Sections)) + .ToList(); } /// @@ -315,16 +305,33 @@ /// The to keep track of the created items. /// The assessment section to create a collection of /// for. - /// The collection of - /// . + /// The collection of + /// . /// An of . + /// Thrown when assembly results cannot be created for . /// Thrown when assembly results are invalid and cannot be exported. private static IEnumerable CreateExportableCombinedSectionAssemblyCollection( IdentifierGenerator idGenerator, ExportableModelRegistry registry, AssessmentSection assessmentSection, - IEnumerable combinedFailureMechanismSectionAssemblyResults) + List failureMechanismSectionCollections) { - return ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection( - idGenerator, registry, combinedFailureMechanismSectionAssemblyResults, assessmentSection); + IEnumerable combinedSectionAssemblyResults = + AssessmentSectionAssemblyFactory.AssembleCombinedPerFailureMechanismSection(assessmentSection) + .ToArray(); + + var exportableCombinedSectionAssemblyCollection = new List(); + + if (combinedSectionAssemblyResults.Any()) + { + failureMechanismSectionCollections.Add( + ExportableFailureMechanismSectionCollectionFactory.CreateExportableFailureMechanismSectionCollection( + idGenerator, registry, assessmentSection.ReferenceLine, combinedSectionAssemblyResults)); + + exportableCombinedSectionAssemblyCollection.AddRange( + ExportableCombinedSectionAssemblyFactory.CreateExportableCombinedSectionAssemblyCollection( + idGenerator, registry, combinedSectionAssemblyResults, assessmentSection)); + } + + return exportableCombinedSectionAssemblyCollection; } } } \ No newline at end of file