public void Read_EntityWithValidValues_SetsCalculationsWithExpectedValues() { // Setup var random = new Random(21); var duneLocationEntityOne = new DuneLocationEntity(); var calculationEntityWithoutOutput = new DuneLocationCalculationEntity { DuneLocationEntity = duneLocationEntityOne }; var duneLocationEntityTwo = new DuneLocationEntity(); var calculationEntityWithOutput = new DuneLocationCalculationEntity { DuneLocationEntity = duneLocationEntityTwo, DuneLocationCalculationOutputEntities = { new DuneLocationCalculationOutputEntity() } }; var collectionEntity = new DuneLocationCalculationForTargetProbabilityCollectionEntity { TargetProbability = random.NextDouble(0, 0.1), DuneLocationCalculationEntities = { calculationEntityWithoutOutput, calculationEntityWithOutput } }; var duneLocationOne = new TestDuneLocation("1"); var duneLocationTwo = new TestDuneLocation("2"); var collector = new ReadConversionCollector(); collector.Read(duneLocationEntityOne, duneLocationOne); collector.Read(duneLocationEntityTwo, duneLocationTwo); // Call DuneLocationCalculationsForTargetProbability calculations = collectionEntity.Read(collector); // Assert Assert.AreEqual(collectionEntity.TargetProbability, calculations.TargetProbability); IEnumerable <DuneLocationCalculation> duneLocationCalculations = calculations.DuneLocationCalculations; Assert.AreEqual(collectionEntity.DuneLocationCalculationEntities.Count, duneLocationCalculations.Count()); DuneLocationCalculation calculationOne = duneLocationCalculations.ElementAt(0); Assert.AreSame(collector.Get(duneLocationEntityOne), calculationOne.DuneLocation); Assert.IsNull(calculationOne.Output); DuneLocationCalculation calculationTwo = duneLocationCalculations.ElementAt(1); Assert.AreSame(collector.Get(duneLocationEntityTwo), calculationTwo.DuneLocation); Assert.IsNotNull(calculationTwo.Output); }
/// <summary> /// Reads the <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/> and uses /// the information to create a <see cref="HydraulicBoundaryLocationCalculationsForTargetProbability"/>. /// </summary> /// <param name="entity">The <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/> to create the /// <see cref="HydraulicBoundaryLocationCalculationsForTargetProbability"/>.</param> /// <param name="collector">The object keeping track of the read operations.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> internal static HydraulicBoundaryLocationCalculationsForTargetProbability Read( this HydraulicLocationCalculationForTargetProbabilityCollectionEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var calculations = new HydraulicBoundaryLocationCalculationsForTargetProbability(entity.TargetProbability); IEnumerable <HydraulicBoundaryLocationCalculation> hydraulicBoundaryLocationCalculations = entity.HydraulicLocationCalculationEntities .Select(hlce => CreateHydraulicBoundaryLocationCalculation(hlce, collector)) .ToArray(); calculations.HydraulicBoundaryLocationCalculations.AddRange(hydraulicBoundaryLocationCalculations); collector.Read(entity, calculations); return(calculations); }
/// <summary> /// Reads the <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> and use the information /// to construct a <see cref="MacroStabilityInwardsSoilProfile1D"/>. /// </summary> /// <param name="entity">The <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> to /// create <see cref="MacroStabilityInwardsSoilProfile1D"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="MacroStabilityInwardsSoilProfile1D"/> or one from the <paramref name="collector"/> /// if the <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> has been read before.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static MacroStabilityInwardsSoilProfile1D Read(this MacroStabilityInwardsSoilProfileOneDEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } IEnumerable <MacroStabilityInwardsSoilLayer1D> layers = entity.MacroStabilityInwardsSoilLayerOneDEntities.OrderBy(sl => sl.Order) .Select(sl => sl.Read()) .ToArray(); var macroStabilityInwardsSoilProfile = new MacroStabilityInwardsSoilProfile1D(entity.Name, entity.Bottom.ToNullAsNaN(), layers); collector.Read(entity, macroStabilityInwardsSoilProfile); return(macroStabilityInwardsSoilProfile); }
/// <summary> /// Read the <see cref="DuneLocationEntity"/> and use the information to construct a <see cref="DuneLocation"/>. /// </summary> /// <param name="entity">The <see cref="DuneLocationEntity"/> to create <see cref="DuneLocation"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="DuneLocation"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> internal static DuneLocation Read(this DuneLocationEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var duneLocation = new DuneLocation(entity.LocationId, entity.Name, new Point2D(entity.LocationX.ToNullAsNaN(), entity.LocationY.ToNullAsNaN()), new DuneLocation.ConstructionProperties { CoastalAreaId = entity.CoastalAreaId, Offset = entity.Offset.ToNullAsNaN(), Orientation = entity.Orientation.ToNullAsNaN(), D50 = entity.D50.ToNullAsNaN() }); collector.Read(entity, duneLocation); return(duneLocation); }
/// <summary> /// Reads the <see cref="PipingSoilProfileEntity"/> and use the information to construct a <see cref="PipingSoilProfile"/>. /// </summary> /// <param name="entity">The <see cref="PipingSoilProfileEntity"/> to create <see cref="PipingSoilProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="PipingSoilProfile"/> or one from the <paramref name="collector"/> if the /// <see cref="PipingSoilProfileEntity"/> has been read before.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static PipingSoilProfile Read(this PipingSoilProfileEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } IEnumerable <PipingSoilLayer> layers = entity.PipingSoilLayerEntities.OrderBy(sl => sl.Order) .Select(sl => sl.Read()) .ToArray(); var pipingSoilProfile = new PipingSoilProfile(entity.Name, entity.Bottom.ToNullAsNaN(), layers, (SoilProfileType)entity.SourceType); collector.Read(entity, pipingSoilProfile); return(pipingSoilProfile); }
/// <summary> /// Read the <see cref="HydraulicLocationEntity"/> and use the information to construct a <see cref="HydraulicBoundaryLocation"/>. /// </summary> /// <param name="entity">The <see cref="HydraulicLocationEntity"/> to create <see cref="HydraulicBoundaryLocation"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="HydraulicBoundaryLocation"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> internal static HydraulicBoundaryLocation Read(this HydraulicLocationEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(entity.LocationId, entity.Name, entity.LocationX.ToNullAsNaN(), entity.LocationY.ToNullAsNaN()); collector.Read(entity, hydraulicBoundaryLocation); return(hydraulicBoundaryLocation); }
public void Read_WithCollector_NewPointAndEntityRegistered() { // Setup const string name = "testName"; var points = new[] { new Point2D(0, 0) }; string pointXml = new Point2DCollectionXmlSerializer().ToXml(points); var entity = new FailureMechanismSectionEntity { Name = name, FailureMechanismSectionPointXml = pointXml }; var collector = new ReadConversionCollector(); // Call FailureMechanismSection section = entity.Read(collector); // Assert Assert.IsNotNull(section); Assert.AreEqual(name, section.Name); Assert.AreEqual(section, collector.Get(entity)); Assert.IsTrue(collector.Contains(entity)); }
/// <summary> /// Read the <see cref="ForeshoreProfileEntity"/> and use the information to construct a <see cref="ForeshoreProfile"/>. /// </summary> /// <param name="entity">The <see cref="ForeshoreProfileEntity"/> to create <see cref="ForeshoreProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="ForeshoreProfile"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <see cref="ForeshoreProfileEntity.GeometryXml"/> /// of <paramref name="entity"/> is <c>null</c> or empty.</exception> internal static ForeshoreProfile Read(this ForeshoreProfileEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } Point2D[] points = new Point2DCollectionXmlSerializer().FromXml(entity.GeometryXml); var foreshoreProfile = new ForeshoreProfile(new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), points, CreateBreakWater(entity.BreakWaterType, entity.BreakWaterHeight), new ForeshoreProfile.ConstructionProperties { Id = entity.Id.DeepClone(), Name = entity.Name.DeepClone(), Orientation = entity.Orientation.ToNullAsNaN(), X0 = entity.X0.ToNullAsNaN() }); collector.Read(entity, foreshoreProfile); return(foreshoreProfile); }
/// <summary> /// Reads the <see cref="PipingStochasticSoilProfileEntity"/> and use the information to /// construct a <see cref="PipingStochasticSoilProfile"/>. /// </summary> /// <param name="entity">The <see cref="PipingStochasticSoilProfileEntity"/> to create /// <see cref="PipingStochasticSoilProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="PipingStochasticSoilProfile"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> internal static PipingStochasticSoilProfile Read(this PipingStochasticSoilProfileEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } PipingSoilProfile soilProfile = entity.ReadSoilProfile(collector); var stochasticSoilProfile = new PipingStochasticSoilProfile(entity.Probability, soilProfile); collector.Read(entity, stochasticSoilProfile); return(stochasticSoilProfile); }
/// <summary> /// Reads the <see cref="HydraulicLocationCalculationCollectionEntity"/> and uses /// the information to update a collection of <see cref="HydraulicBoundaryLocationCalculation"/>. /// </summary> /// <param name="entity">The <see cref="HydraulicLocationCalculationEntity"/> to update the /// <see cref="HydraulicBoundaryLocationCalculation"/>.</param> /// <param name="calculations">The target of the read operation.</param> /// <param name="collector">The object keeping track of the read operations.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> internal static void Read(this HydraulicLocationCalculationCollectionEntity entity, IEnumerable <HydraulicBoundaryLocationCalculation> calculations, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (calculations == null) { throw new ArgumentNullException(nameof(calculations)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } Dictionary <HydraulicBoundaryLocation, HydraulicBoundaryLocationCalculation> calculationsLookup = calculations.ToDictionary(calc => calc.HydraulicBoundaryLocation, calc => calc); foreach (HydraulicLocationCalculationEntity calculationEntity in entity.HydraulicLocationCalculationEntities) { HydraulicBoundaryLocation hydraulicBoundaryLocation = collector.Get(calculationEntity.HydraulicLocationEntity); HydraulicBoundaryLocationCalculation calculation = calculationsLookup[hydraulicBoundaryLocation]; calculationEntity.Read(calculation); } }
/// <summary> /// Reads the <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> and use the information /// to construct a <see cref="MacroStabilityInwardsSoilProfile2D"/>. /// </summary> /// <param name="entity">The <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> to /// create <see cref="MacroStabilityInwardsSoilProfile2D"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="MacroStabilityInwardsSoilProfile2D"/> or one from the <paramref name="collector"/> /// if the <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> has been read before.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static MacroStabilityInwardsSoilProfile2D Read(this MacroStabilityInwardsSoilProfileTwoDEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } IEnumerable <MacroStabilityInwardsSoilLayer2D> layers = entity.MacroStabilityInwardsSoilLayerTwoDEntities .OrderBy(sl => sl.Order) .Select(sl => sl.Read()) .ToArray(); IEnumerable <MacroStabilityInwardsPreconsolidationStress> preconsolidationStresses = entity.MacroStabilityInwardsPreconsolidationStressEntities .OrderBy(stressEntity => stressEntity.Order) .Select(stressEntity => stressEntity.Read()) .ToArray(); var soilProfile = new MacroStabilityInwardsSoilProfile2D(entity.Name, layers, preconsolidationStresses); collector.Read(entity, soilProfile); return(soilProfile); }
private static HydraulicBoundaryLocationCalculation CreateHydraulicBoundaryLocationCalculation(HydraulicLocationCalculationEntity calculationEntity, ReadConversionCollector collector) { var calculation = new HydraulicBoundaryLocationCalculation(collector.Get(calculationEntity.HydraulicLocationEntity)); calculationEntity.Read(calculation); return(calculation); }
private static DuneLocationCalculation CreateDuneLocationCalculation(DuneLocationCalculationEntity calculationEntity, ReadConversionCollector collector) { var calculation = new DuneLocationCalculation(collector.Get(calculationEntity.DuneLocationEntity)); calculationEntity.Read(calculation); return(calculation); }
/// <summary> /// Reads the <see cref="HeightStructureEntity"/> and use the information to update a /// <see cref="HeightStructure"/>. /// </summary> /// <param name="entity">The <see cref="HeightStructureEntity"/> to create <see cref="HeightStructure"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="HeightStructure"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> internal static HeightStructure Read(this HeightStructureEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var structure = new HeightStructure(new HeightStructure.ConstructionProperties { Name = entity.Name, Id = entity.Id, Location = new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), StructureNormalOrientation = (RoundedDouble)entity.StructureNormalOrientation.ToNullAsNaN(), LevelCrestStructure = { Mean = (RoundedDouble)entity.LevelCrestStructureMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.LevelCrestStructureStandardDeviation.ToNullAsNaN() }, FlowWidthAtBottomProtection = { Mean = (RoundedDouble)entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN() }, CriticalOvertoppingDischarge = { Mean = (RoundedDouble)entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN() }, WidthFlowApertures = { Mean = (RoundedDouble)entity.WidthFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.WidthFlowAperturesStandardDeviation.ToNullAsNaN() }, FailureProbabilityStructureWithErosion = entity.FailureProbabilityStructureWithErosion.ToNullAsNaN(), StorageStructureArea = { Mean = (RoundedDouble)entity.StorageStructureAreaMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN() }, AllowedLevelIncreaseStorage = { Mean = (RoundedDouble)entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN() } }); collector.Read(entity, structure); return(structure); }
private static void ReadFailureMechanismSectionResults(this IFailureMechanismEntity entity, SpecificFailureMechanism specificFailureMechanism, ReadConversionCollector collector) { foreach (NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity sectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.NonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntities)) { FailureMechanismSection failureMechanismSection = collector.Get(sectionResultEntity.FailureMechanismSectionEntity); NonAdoptableWithProfileProbabilityFailureMechanismSectionResult sectionResult = specificFailureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection)); sectionResultEntity.Read(sectionResult); } }
public void Read_EntityNotReadBefore_RegisterEntity() { // Setup var entity = new ClosingStructureEntity { Name = "name", Id = "id" }; var collector = new ReadConversionCollector(); // Precondition Assert.IsFalse(collector.Contains(entity)); // Call ClosingStructure calculation = entity.Read(collector); // Assert Assert.IsTrue(collector.Contains(entity)); Assert.AreSame(calculation, collector.Get(entity)); }
/// <summary> /// Reads the <see cref="DikeProfileEntity"/> and use the information to update a /// <see cref="DikeProfile"/>. /// </summary> /// <param name="entity">The <see cref="DikeProfileEntity"/> to create <see cref="DikeProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="DikeProfile"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <see cref="DikeProfileEntity.DikeGeometryXml"/> /// or <see cref="DikeProfileEntity.ForeshoreXml"/> of <paramref name="entity"/> is <c>null</c> or empty.</exception> internal static DikeProfile Read(this DikeProfileEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var dikeProfile = new DikeProfile(new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), new RoughnessPointCollectionXmlSerializer().FromXml(entity.DikeGeometryXml), new Point2DCollectionXmlSerializer().FromXml(entity.ForeshoreXml), CreateBreakWater(entity), CreateProperties(entity)); collector.Read(entity, dikeProfile); return(dikeProfile); }
/// <summary> /// Reads the <see cref="MacroStabilityInwardsStochasticSoilProfileEntity"/> and use the information to /// construct a <see cref="MacroStabilityInwardsStochasticSoilProfile"/>. /// </summary> /// <param name="entity">The <see cref="MacroStabilityInwardsStochasticSoilProfileEntity"/> to create /// <see cref="MacroStabilityInwardsStochasticSoilProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="MacroStabilityInwardsStochasticSoilProfile"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static MacroStabilityInwardsStochasticSoilProfile Read(this MacroStabilityInwardsStochasticSoilProfileEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(entity.Probability, entity.ReadSoilProfile(collector)); collector.Read(entity, stochasticSoilProfile); return(stochasticSoilProfile); }
/// <summary> /// Reads the <see cref="ClosingStructureEntity"/> and use the information to update a /// <see cref="ClosingStructure"/>. /// </summary> /// <param name="entity">The <see cref="ClosingStructureEntity"/> to create <see cref="ClosingStructure"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="ClosingStructure"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> internal static ClosingStructure Read(this ClosingStructureEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var structure = new ClosingStructure(new ClosingStructure.ConstructionProperties { Name = entity.Name, Id = entity.Id, Location = new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), StructureNormalOrientation = (RoundedDouble)entity.StructureNormalOrientation.ToNullAsNaN(), StorageStructureArea = { Mean = (RoundedDouble)entity.StorageStructureAreaMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN() }, AllowedLevelIncreaseStorage = { Mean = (RoundedDouble)entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN() }, WidthFlowApertures = { Mean = (RoundedDouble)entity.WidthFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.WidthFlowAperturesStandardDeviation.ToNullAsNaN() }, LevelCrestStructureNotClosing = { Mean = (RoundedDouble)entity.LevelCrestStructureNotClosingMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.LevelCrestStructureNotClosingStandardDeviation.ToNullAsNaN() }, InsideWaterLevel = { Mean = (RoundedDouble)entity.InsideWaterLevelMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.InsideWaterLevelStandardDeviation.ToNullAsNaN() }, ThresholdHeightOpenWeir = { Mean = (RoundedDouble)entity.ThresholdHeightOpenWeirMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.ThresholdHeightOpenWeirStandardDeviation.ToNullAsNaN() }, AreaFlowApertures = { Mean = (RoundedDouble)entity.AreaFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AreaFlowAperturesStandardDeviation.ToNullAsNaN() }, CriticalOvertoppingDischarge = { Mean = (RoundedDouble)entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN() }, FlowWidthAtBottomProtection = { Mean = (RoundedDouble)entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN() }, ProbabilityOpenStructureBeforeFlooding = entity.ProbabilityOpenStructureBeforeFlooding.ToNullAsNaN(), FailureProbabilityOpenStructure = entity.FailureProbabilityOpenStructure.ToNullAsNaN(), IdenticalApertures = entity.IdenticalApertures, FailureProbabilityReparation = entity.FailureProbabilityReparation.ToNullAsNaN(), InflowModelType = (ClosingStructureInflowModelType)entity.InflowModelType }); collector.Read(entity, structure); return(structure); }
/// <summary> /// Reads the <see cref="StabilityPointStructureEntity"/> and use the information to update a /// <see cref="StabilityPointStructure"/>. /// </summary> /// <param name="entity">The <see cref="StabilityPointStructureEntity"/> to create <see cref="StabilityPointStructure"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="StabilityPointStructure"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> internal static StabilityPointStructure Read(this StabilityPointStructureEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var structure = new StabilityPointStructure(new StabilityPointStructure.ConstructionProperties { Name = entity.Name, Id = entity.Id, Location = new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), StructureNormalOrientation = (RoundedDouble)entity.StructureNormalOrientation.ToNullAsNaN(), StorageStructureArea = { Mean = (RoundedDouble)entity.StorageStructureAreaMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN() }, AllowedLevelIncreaseStorage = { Mean = (RoundedDouble)entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN() }, FlowWidthAtBottomProtection = { Mean = (RoundedDouble)entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN() }, InsideWaterLevel = { Mean = (RoundedDouble)entity.InsideWaterLevelMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.InsideWaterLevelStandardDeviation.ToNullAsNaN() }, ThresholdHeightOpenWeir = { Mean = (RoundedDouble)entity.ThresholdHeightOpenWeirMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.ThresholdHeightOpenWeirStandardDeviation.ToNullAsNaN() }, CriticalOvertoppingDischarge = { Mean = (RoundedDouble)entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN() }, WidthFlowApertures = { Mean = (RoundedDouble)entity.WidthFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.WidthFlowAperturesStandardDeviation.ToNullAsNaN() }, ConstructiveStrengthLinearLoadModel = { Mean = (RoundedDouble)entity.ConstructiveStrengthLinearLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation.ToNullAsNaN() }, ConstructiveStrengthQuadraticLoadModel = { Mean = (RoundedDouble)entity.ConstructiveStrengthQuadraticLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation.ToNullAsNaN() }, BankWidth = { Mean = (RoundedDouble)entity.BankWidthMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.BankWidthStandardDeviation.ToNullAsNaN() }, InsideWaterLevelFailureConstruction = { Mean = (RoundedDouble)entity.InsideWaterLevelFailureConstructionMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.InsideWaterLevelFailureConstructionStandardDeviation.ToNullAsNaN() }, EvaluationLevel = (RoundedDouble)entity.EvaluationLevel.ToNullAsNaN(), LevelCrestStructure = { Mean = (RoundedDouble)entity.LevelCrestStructureMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.LevelCrestStructureStandardDeviation.ToNullAsNaN() }, VerticalDistance = (RoundedDouble)entity.VerticalDistance.ToNullAsNaN(), FailureProbabilityRepairClosure = entity.FailureProbabilityRepairClosure.ToNullAsNaN(), FailureCollisionEnergy = { Mean = (RoundedDouble)entity.FailureCollisionEnergyMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.FailureCollisionEnergyCoefficientOfVariation.ToNullAsNaN() }, ShipMass = { Mean = (RoundedDouble)entity.ShipMassMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ShipMassCoefficientOfVariation.ToNullAsNaN() }, ShipVelocity = { Mean = (RoundedDouble)entity.ShipVelocityMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.ShipVelocityCoefficientOfVariation.ToNullAsNaN() }, LevellingCount = entity.LevellingCount, ProbabilityCollisionSecondaryStructure = entity.ProbabilityCollisionSecondaryStructure.ToNullAsNaN(), FlowVelocityStructureClosable = { Mean = (RoundedDouble)entity.FlowVelocityStructureClosableMean.ToNullAsNaN() }, StabilityLinearLoadModel = { Mean = (RoundedDouble)entity.StabilityLinearLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StabilityLinearLoadModelCoefficientOfVariation.ToNullAsNaN() }, StabilityQuadraticLoadModel = { Mean = (RoundedDouble)entity.StabilityQuadraticLoadModelMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StabilityQuadraticLoadModelCoefficientOfVariation.ToNullAsNaN() }, AreaFlowApertures = { Mean = (RoundedDouble)entity.AreaFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AreaFlowAperturesStandardDeviation.ToNullAsNaN() }, InflowModelType = (StabilityPointStructureInflowModelType)entity.InflowModelType }); collector.Read(entity, structure); return(structure); }