Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs =================================================================== diff -u -r583a729a502f52ca415627efcb2287886e8efb1d -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 583a729a502f52ca415627efcb2287886e8efb1d) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e) @@ -23,6 +23,7 @@ using System.Collections.Generic; using Application.Ringtoets.Storage.DbContext; using Core.Common.Utils; +using Ringtoets.ClosingStructures.Data; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.GrassCoverErosionInwards.Data; @@ -50,6 +51,7 @@ private readonly Dictionary foreshoreProfiles = CreateDictionary(); private readonly Dictionary grassCoverErosionInwardsCalculations = CreateDictionary(); private readonly Dictionary heightStructures = CreateDictionary(); + private readonly Dictionary closingStructures = CreateDictionary(); private static Dictionary CreateDictionary() { @@ -847,5 +849,77 @@ } #endregion + + #region ClosingStructureEntity: Read, Contains, Get + + /// + /// Registers a read operation for and the + /// that was constructed with the information. + /// + /// The that was read. + /// The that was constructed. + /// Thrown when either: + /// + /// is null + /// is null + /// + internal void Read(ClosingStructureEntity entity, ClosingStructure model) + { + if (entity == null) + { + throw new ArgumentNullException("entity"); + } + if (model == null) + { + throw new ArgumentNullException("model"); + } + + closingStructures[entity] = model; + } + + /// + /// Checks whether a read operation has been registered for a given . + /// + /// The to check for. + /// true if the was read before, false otherwise. + /// Thrown when is null. + internal bool Contains(ClosingStructureEntity entity) + { + if (entity == null) + { + throw new ArgumentNullException("entity"); + } + return closingStructures.ContainsKey(entity); + } + + /// + /// Obtains the which was read for the + /// given . + /// + /// The for which a read + /// operation has been registered. + /// The constructed . + /// Thrown when is null. + /// Thrown when no read operation has + /// been registered for . + /// Use to find out whether a + /// read operation has been registered for . + internal ClosingStructure Get(ClosingStructureEntity entity) + { + if (entity == null) + { + throw new ArgumentNullException("entity"); + } + try + { + return closingStructures[entity]; + } + catch (KeyNotFoundException e) + { + throw new InvalidOperationException(e.Message, e); + } + } + + #endregion } } \ No newline at end of file