Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs =================================================================== diff -u -rfe9d1b89f949a4c7629264b6d7ac22d1c7a8845e -re6fc9977574d3546472607de8f41060a11c81120 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision fe9d1b89f949a4c7629264b6d7ac22d1c7a8845e) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision e6fc9977574d3546472607de8f41060a11c81120) @@ -102,38 +102,25 @@ { CreateDirectory(nestedFolderPath); - var exportedCalculations = new List(); + var continueExport = true; var exportedGroups = new List(); + var exportedCalculations = new List(); foreach (ICalculationBase calculationItem in groupToExport.Children) { - if (calculationItem is MacroStabilityInwardsCalculation calculation) + if (calculationItem is CalculationGroup nestedGroup) { - if (!calculation.HasOutput) - { - log.WarnFormat(Resources.MacroStabilityInwardsCalculationGroupExporter_Export_Calculation_0_has_no_output_and_is_skipped, calculation.Name); - continue; - } - - bool exportSucceeded = Export(calculation, nestedFolderPath, exportedCalculations); - if (!exportSucceeded) - { - return false; - } - - exportedCalculations.Add(calculation); + continueExport = ExportCalculationGroup(nestedGroup, nestedFolderPath, exportedGroups); } - if (calculationItem is CalculationGroup nestedGroup) + if (calculationItem is MacroStabilityInwardsCalculation calculation) { - string uniqueGroupName = NamingHelper.GetUniqueName(exportedGroups, nestedGroup.Name, group => group.Name); - bool exportSucceeded = Export(nestedGroup, Path.Combine(nestedFolderPath, uniqueGroupName)); - if (!exportSucceeded) - { - return false; - } + continueExport = ExportCalculation(calculation, nestedFolderPath, exportedCalculations); + } - exportedGroups.Add(nestedGroup); + if (!continueExport) + { + return false; } } @@ -148,6 +135,41 @@ } } + private bool ExportCalculationGroup(CalculationGroup nestedGroup, string nestedFolderPath, ICollection exportedGroups) + { + string uniqueGroupName = NamingHelper.GetUniqueName(exportedGroups, nestedGroup.Name, group => group.Name); + + bool exportSucceeded = Export(nestedGroup, Path.Combine(nestedFolderPath, uniqueGroupName)); + if (!exportSucceeded) + { + return false; + } + + exportedGroups.Add(nestedGroup); + + return true; + } + + private bool ExportCalculation(MacroStabilityInwardsCalculation calculation, string nestedFolderPath, ICollection exportedCalculations) + { + if (!calculation.HasOutput) + { + log.WarnFormat(Resources.MacroStabilityInwardsCalculationGroupExporter_Export_Calculation_0_has_no_output_and_is_skipped, calculation.Name); + } + else + { + bool exportSucceeded = Export(calculation, nestedFolderPath, exportedCalculations); + if (!exportSucceeded) + { + return false; + } + + exportedCalculations.Add(calculation); + } + + return true; + } + private bool Export(MacroStabilityInwardsCalculation calculation, string nestedFolderPath, IEnumerable exportedCalculations) { string filePath = GetCalculationFilePath(calculation, nestedFolderPath, exportedCalculations);