Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsConfigurationExporter.cs =================================================================== diff -u -r90555cd02cecb2d187e60946deb3d5415cbb3b18 -r467a5dba1d4b29b2035d6d034a083125854077dc --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsConfigurationExporter.cs (.../GrassCoverErosionOutwardsConfigurationExporter.cs) (revision 90555cd02cecb2d187e60946deb3d5415cbb3b18) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/GrassCoverErosionOutwardsConfigurationExporter.cs (.../GrassCoverErosionOutwardsConfigurationExporter.cs) (revision 467a5dba1d4b29b2035d6d034a083125854077dc) @@ -19,10 +19,56 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.IO; +using Core.Common.IO.Exceptions; +using Core.Common.Utils; +using log4net; +using Ringtoets.Common.Data.Calculation; + namespace Ringtoets.GrassCoverErosionOutwards.IO { - public class GrassCoverErosionOutwardsConfigurationExporter + /// + /// Exports a grass cover erosion outwards configuration and stores it as an XML file. + /// + public class GrassCoverErosionOutwardsConfigurationExporter : IFileExporter { - + private static readonly ILog log = LogManager.GetLogger(typeof(GrassCoverErosionOutwardsConfigurationExporter)); + + private CalculationGroup calculationGroup; + private string filePath; + + /// + /// Creates a new instance of . + /// + /// The calculation group to export. + /// The path of the XML file to export to. + /// Thrown when is null. + /// Thrown when is invalid. + public GrassCoverErosionOutwardsConfigurationExporter(CalculationGroup calculationGroup, string filePath) + { + if (calculationGroup == null) + { + throw new ArgumentNullException(nameof(calculationGroup)); + } + IOUtils.ValidateFilePath(filePath); + this.calculationGroup = calculationGroup; + this.filePath = filePath; + } + + public bool Export() + { + try + { + new GrassCoverErosionOutwardsConfigurationWriter().Write(calculationGroup, filePath); + } + catch (CriticalFileWriteException e) + { + log.ErrorFormat("{0} Er is geen configuratie geƫxporteerd.", e.Message); + return false; + } + + return true; + } } } \ No newline at end of file