/// <summary>
        /// Creates a <see cref="ForeshoreProfileEntity"/> based on the information of the <see cref="ForeshoreProfile"/>.
        /// </summary>
        /// <param name="foreshoreProfile">The foreshore profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">The index at which <paramref name="foreshoreProfile"/> resides within its parent.</param>
        /// <returns>A new <see cref="ForeshoreProfileEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static ForeshoreProfileEntity Create(this ForeshoreProfile foreshoreProfile, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(foreshoreProfile))
            {
                return(registry.Get(foreshoreProfile));
            }

            var foreshoreProfileEntity = new ForeshoreProfileEntity
            {
                Id          = foreshoreProfile.Id.DeepClone(),
                Name        = foreshoreProfile.Name.DeepClone(),
                GeometryXml = new Point2DCollectionXmlSerializer().ToXml(foreshoreProfile.Geometry),
                X           = foreshoreProfile.WorldReferencePoint.X,
                Y           = foreshoreProfile.WorldReferencePoint.Y,
                X0          = foreshoreProfile.X0,
                Orientation = foreshoreProfile.Orientation,
                Order       = order
            };

            if (foreshoreProfile.HasBreakWater)
            {
                foreshoreProfileEntity.BreakWaterHeight = foreshoreProfile.BreakWater.Height;
                foreshoreProfileEntity.BreakWaterType   = Convert.ToByte(foreshoreProfile.BreakWater.Type);
            }

            registry.Register(foreshoreProfileEntity, foreshoreProfile);

            return(foreshoreProfileEntity);
        }
        /// <summary>
        /// Creates a <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/> based on the information
        /// of the <paramref name="calculations"/>.
        /// </summary>
        /// <param name="calculations">
        /// The collection of <see cref="HydraulicBoundaryLocationCalculationsForTargetProbability"/>
        /// to create a database entity for.
        /// </param>
        /// <param name="calculationType">The type of calculation the entity should be created for.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculations"/> or <paramref name="registry"/> is <c>null</c>.</exception>
        internal static HydraulicLocationCalculationForTargetProbabilityCollectionEntity Create(this HydraulicBoundaryLocationCalculationsForTargetProbability calculations,
                                                                                                HydraulicBoundaryLocationCalculationType calculationType,
                                                                                                int order,
                                                                                                PersistenceRegistry registry)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(calculations))
            {
                return(registry.Get(calculations));
            }

            var collectionEntity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity
            {
                HydraulicBoundaryLocationCalculationType = Convert.ToByte(calculationType),
                TargetProbability = calculations.TargetProbability,
                Order             = order
            };

            foreach (HydraulicBoundaryLocationCalculation calculation in calculations.HydraulicBoundaryLocationCalculations)
            {
                collectionEntity.HydraulicLocationCalculationEntities.Add(calculation.Create(registry));
            }

            registry.Register(collectionEntity, calculations);
            return(collectionEntity);
        }
Exemple #3
0
        /// <summary>
        /// Creates a <see cref="HydraulicLocationEntity"/> based on the information of the <see cref="HydraulicBoundaryLocation"/>.
        /// </summary>
        /// <param name="location">The location to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="HydraulicLocationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> or <param name="location"></param>
        /// is <c>null</c>.</exception>
        internal static HydraulicLocationEntity Create(this HydraulicBoundaryLocation location, PersistenceRegistry registry, int order)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(location))
            {
                return(registry.Get(location));
            }

            var entity = new HydraulicLocationEntity
            {
                LocationId = location.Id,
                Name       = location.Name.DeepClone(),
                LocationX  = location.Location.X.ToNaNAsNull(),
                LocationY  = location.Location.Y.ToNaNAsNull(),
                Order      = order
            };

            registry.Register(entity, location);
            return(entity);
        }
Exemple #4
0
        /// <summary>
        /// Creates a <see cref="FailureMechanismSectionEntity"/> based on the information of the <see cref="FailureMechanismSection"/>.
        /// </summary>
        /// <param name="section">The section to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="FailureMechanismSectionEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static FailureMechanismSectionEntity Create(this FailureMechanismSection section, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var failureMechanismSectionEntity = new FailureMechanismSectionEntity
            {
                Name = section.Name.DeepClone(),
                FailureMechanismSectionPointXml = new Point2DCollectionXmlSerializer().ToXml(section.Points)
            };

            registry.Register(failureMechanismSectionEntity, section);

            return(failureMechanismSectionEntity);
        }