// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. 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; } } }