using System.Text; namespace Deltares.Dam.Data { /// /// This class helps to build cvs export data. Everytime the builder is ended by calling Build() method, /// the builder is reset and can be used to construct a new CvsExportData item. /// internal class DamProjectCalculatorCsvExportDataBuilder { private Dike Dike { get; set; } private Scenario Scenario { get; set; } private DamFailureMechanismeCalculationSpecification FailureMechanismSystemType { get; set; } private AnalysisType AnalysisType { get; set; } private ProbabilisticType ProbabilisticType { get; set; } private StringBuilder Message { get; set; } /// /// Instantiate a new instance of the with general settings which to use in creating /// . /// /// The for which to create . /// The for which to create . /// The for which to create . /// The for which to create . /// The for which to create public DamProjectCalculatorCsvExportDataBuilder(Dike dike, Scenario scenario, DamFailureMechanismeCalculationSpecification damFailureMechanismCalculationSpecification, AnalysisType analysisType, ProbabilisticType probabilisticType) { Dike = dike; Scenario = scenario; FailureMechanismSystemType = damFailureMechanismCalculationSpecification; AnalysisType = analysisType; ProbabilisticType = probabilisticType; Message = new StringBuilder(); } /// /// Returns a new instance of . Messages that were added using are added to the /// and the message queue is cleared. /// /// The for which to create this . /// The to set for the to be created . Default is the 0th . /// The newly constructed with messages appended using . public CsvExportData Build(SoilGeometryProbability soilGeometryProbability, StabilityKernelType kernelType = (StabilityKernelType) 0) { return Build(soilGeometryProbability, kernelType, 0); } /// /// Returns a new instance of . Messages that were added using are added to the /// and the message queue is cleared. /// /// The for which to create this . /// An optional index to associate the with some other object of a list. /// The newly constructed with messages appended using . public CsvExportData Build(SoilGeometryProbability soilGeometryProbability, int index) { return Build(soilGeometryProbability, 0, index); } private CsvExportData Build(SoilGeometryProbability soilGeometryProbability, StabilityKernelType kernelType, int index) { var data = new CsvExportData( Message.ToString(), Dike, FailureMechanismSystemType, Scenario, soilGeometryProbability.SoilProfile, soilGeometryProbability.SoilGeometry2DName, AnalysisType, index, ProbabilisticType); data.SelectedStabilityKernelType = kernelType; Message.Clear(); return data; } /// /// Append a new message to the message queue. /// /// The messages to add to the queue. /// This instance of the so that consecutive calls to methods /// of can be chained. public DamProjectCalculatorCsvExportDataBuilder Append(params object[] messageParts) { foreach (var messagePart in messageParts) { Message.Append(messagePart); } return this; } } }