Exemple #1
0
        internal static EventTreeEntity Create(this EventTree model, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new EventTreeEntity
            {
                Name               = model.Name.DeepClone(),
                Details            = model.Details.DeepClone(),
                Summary            = model.Summary.DeepClone(),
                Color              = model.Color.ToHexString(),
                TreeEventEntity    = model.MainTreeEvent?.Create(registry),
                NeedsSpecification = Convert.ToByte(model.NeedsSpecification)
            };

            registry.Register(model, entity);

            return(entity);
        }
Exemple #2
0
        internal static TreeEventEntity Create(this TreeEvent model, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new TreeEventEntity
            {
                Name                         = model.Name.DeepClone(),
                Details                      = model.Details.DeepClone(),
                Summary                      = model.Summary.DeepClone(),
                FixedProbability             = ((double)model.FixedProbability).ToNaNAsNull(),
                ProbabilitySpecificationType = Convert.ToByte(model.ProbabilitySpecificationType),
                Information                  = model.Information.DeepClone(),
                Discussion                   = model.Discussion.DeepClone(),
                // Add passphrase
            };

            AddExpertClassEstimations(entity, model, registry);
            AddFragilityCurveElements(entity, model, registry);

            if (model.FailingEvent != null)
            {
                entity.TreeEventEntity3 = model.FailingEvent.Create(registry);
            }

            if (model.PassingEvent != null)
            {
                entity.TreeEventEntity2 = model.PassingEvent.Create(registry);
            }

            registry.Register(model, entity);

            return(entity);
        }
        internal static FragilityCurveElementEntity Create(this FragilityCurveElement model, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new FragilityCurveElementEntity
            {
                Probability = ((double)model.Probability).ToNaNAsNull(),
                WaterLevel  = model.WaterLevel.ToNaNAsNull()
            };

            registry.Register(model, entity);

            return(entity);
        }
Exemple #4
0
        internal static ExpertEntity Create(this Expert model, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new ExpertEntity
            {
                PersonEntity = ((Person)model).Create(registry),
                Expertise    = model.Expertise.DeepClone(),
                Organisation = model.Organisation.DeepClone()
            };

            registry.Register(model, entity);

            return(entity);
        }
Exemple #5
0
        internal static PersonEntity Create(this Person model, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new PersonEntity
            {
                Name      = model.Name.DeepClone(),
                Email     = model.Email.DeepClone(),
                Telephone = model.Telephone.DeepClone()
            };

            registry.Register(model, entity);

            return(entity);
        }
Exemple #6
0
        internal static HydraulicConditionElementEntity Create(this HydraulicCondition model, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new HydraulicConditionElementEntity
            {
                FragilityCurveElementEntity = ((FragilityCurveElement)model).Create(registry),
                WaveHeight = model.WaveHeight.ToNaNAsNull(),
                WavePeriod = model.WavePeriod.ToNaNAsNull()
            };

            registry.Register(model, entity);

            return(entity);
        }