// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets 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;
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.Common.Data.Hydraulics;
using Ringtoets.Common.Data.Structures;
using Ringtoets.DuneErosion.Data;
using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.HeightStructures.Data;
using Ringtoets.Piping.Data.SoilProfile;
using Ringtoets.Piping.Primitives;
using Ringtoets.StabilityPointStructures.Data;
namespace Application.Ringtoets.Storage.Read
{
///
/// Class that can be used to keep track of data model objects which were initialized during a read operation
/// from the database. Can be used to reuse objects when reading an already read entity.
///
internal class ReadConversionCollector
{
private readonly Dictionary pipingStochasticSoilModels =
CreateDictionary();
private readonly Dictionary pipingStochasticSoilProfiles =
CreateDictionary();
private readonly Dictionary pipingSoilProfiles =
CreateDictionary();
private readonly Dictionary surfaceLines =
CreateDictionary();
private readonly Dictionary hydraulicBoundaryLocations =
CreateDictionary();
private readonly Dictionary grassCoverErosionOutwardsHydraulicBoundaryLocations =
CreateDictionary();
private readonly Dictionary duneLocations =
CreateDictionary();
private readonly Dictionary failureMechanismSections =
CreateDictionary();
private readonly Dictionary dikeProfiles =
CreateDictionary();
private readonly Dictionary foreshoreProfiles =
CreateDictionary();
private readonly Dictionary grassCoverErosionInwardsCalculations =
CreateDictionary();
private readonly Dictionary heightStructures =
CreateDictionary();
private readonly Dictionary closingStructures =
CreateDictionary();
private readonly Dictionary stabilityPointStructures =
CreateDictionary();
private readonly Dictionary> heightStructuresCalculations =
CreateDictionary>();
private readonly Dictionary> closingStructuresCalculations =
CreateDictionary>();
private readonly Dictionary> stabilityPointStructuresCalculations =
CreateDictionary>();
private static Dictionary CreateDictionary()
{
return new Dictionary(new ReferenceEqualityComparer());
}
#region StochasticSoilModelEntity: 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(StochasticSoilModelEntity entity, PipingStochasticSoilModel model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
pipingStochasticSoilModels[entity] = model;
}
///
/// Checks whether a read operations has been registered for the given .
///
/// The to check for.
/// true if the was read before, false otherwise.
/// Thrown when is null.
internal bool Contains(StochasticSoilModelEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return pipingStochasticSoilModels.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 PipingStochasticSoilModel Get(StochasticSoilModelEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return pipingStochasticSoilModels[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region StochasticSoilProfileEntity: 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(StochasticSoilProfileEntity entity, PipingStochasticSoilProfile model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
pipingStochasticSoilProfiles[entity] = model;
}
///
/// Checks whether a read operations has been registered for the given .
///
/// The to check for.
/// true if the was read before, false otherwise.
/// Thrown when is null.
internal bool Contains(StochasticSoilProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return pipingStochasticSoilProfiles.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 PipingStochasticSoilProfile Get(StochasticSoilProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return pipingStochasticSoilProfiles[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region SoilProfileEntity: 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(SoilProfileEntity entity, PipingSoilProfile model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
pipingSoilProfiles[entity] = model;
}
///
/// Checks whether a read operations has been registered for the given .
///
/// The to check for.
/// true if the was read before, false otherwise.
/// Thrown when is null.
internal bool Contains(SoilProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return pipingSoilProfiles.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 PipingSoilProfile Get(SoilProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return pipingSoilProfiles[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region SurfaceLineEntity: 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(SurfaceLineEntity entity, PipingSurfaceLine model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
surfaceLines[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(SurfaceLineEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return surfaceLines.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 PipingSurfaceLine Get(SurfaceLineEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return surfaceLines[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region HydraulicLocationEntity: 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(HydraulicLocationEntity entity, HydraulicBoundaryLocation model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
hydraulicBoundaryLocations[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(HydraulicLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return hydraulicBoundaryLocations.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 HydraulicBoundaryLocation Get(HydraulicLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return hydraulicBoundaryLocations[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region DuneLocationEntity: 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(DuneLocationEntity entity, DuneLocation model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
duneLocations[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(DuneLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return duneLocations.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 DuneLocation Get(DuneLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return duneLocations[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region FailureMechanismSectionEntity: 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(FailureMechanismSectionEntity entity, FailureMechanismSection model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
failureMechanismSections[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(FailureMechanismSectionEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return failureMechanismSections.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 FailureMechanismSection Get(FailureMechanismSectionEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return failureMechanismSections[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region DikeProfileEntity: 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(DikeProfileEntity entity, DikeProfile model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
dikeProfiles[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(DikeProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return dikeProfiles.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 DikeProfile Get(DikeProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return dikeProfiles[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region ForeshoreProfileEntity: 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(ForeshoreProfileEntity entity, ForeshoreProfile model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
foreshoreProfiles[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(ForeshoreProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return foreshoreProfiles.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 ForeshoreProfile Get(ForeshoreProfileEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return foreshoreProfiles[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region GrassCoverErosionInwardsCalculationEntity: 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(GrassCoverErosionInwardsCalculationEntity entity, GrassCoverErosionInwardsCalculation model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
grassCoverErosionInwardsCalculations[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(GrassCoverErosionInwardsCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return grassCoverErosionInwardsCalculations.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 GrassCoverErosionInwardsCalculation Get(GrassCoverErosionInwardsCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return grassCoverErosionInwardsCalculations[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region GrassCoverErosionOutwardsHydraulicLocationEntity: 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(GrassCoverErosionOutwardsHydraulicLocationEntity entity, HydraulicBoundaryLocation model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
grassCoverErosionOutwardsHydraulicBoundaryLocations[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(GrassCoverErosionOutwardsHydraulicLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return grassCoverErosionOutwardsHydraulicBoundaryLocations.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 HydraulicBoundaryLocation Get(GrassCoverErosionOutwardsHydraulicLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return grassCoverErosionOutwardsHydraulicBoundaryLocations[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region HeightStructureEntity: 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(HeightStructureEntity entity, HeightStructure model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
heightStructures[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(HeightStructureEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return heightStructures.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 HeightStructure Get(HeightStructureEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return heightStructures[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region HeightStructuresCalculationEntity: 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 any input parameter is null.
internal void Read(HeightStructuresCalculationEntity entity, StructuresCalculation model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
heightStructuresCalculations[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(HeightStructuresCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return heightStructuresCalculations.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 StructuresCalculation Get(HeightStructuresCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return heightStructuresCalculations[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#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(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(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(nameof(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(nameof(entity));
}
try
{
return closingStructures[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region ClosingStructuresCalculationEntity: 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 any input parameter is null.
internal void Read(ClosingStructuresCalculationEntity entity, StructuresCalculation model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
closingStructuresCalculations[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(ClosingStructuresCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return closingStructuresCalculations.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 StructuresCalculation Get(ClosingStructuresCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return closingStructuresCalculations[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region StabilityPointStructureEntity: 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(StabilityPointStructureEntity entity, StabilityPointStructure model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
stabilityPointStructures[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(StabilityPointStructureEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return stabilityPointStructures.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 StabilityPointStructure Get(StabilityPointStructureEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return stabilityPointStructures[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
#region StabilityPointStructuresCalculationEntity: 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 any input parameter is null.
internal void Read(StabilityPointStructuresCalculationEntity entity, StructuresCalculation model)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
stabilityPointStructuresCalculations[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(StabilityPointStructuresCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
return stabilityPointStructuresCalculations.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 StructuresCalculation Get(StabilityPointStructuresCalculationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
try
{
return stabilityPointStructuresCalculations[entity];
}
catch (KeyNotFoundException e)
{
throw new InvalidOperationException(e.Message, e);
}
}
#endregion
}
}