internal static Person Read(this PersonEntity 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 person = new Person
            {
                Name      = entity.Name,
                Email     = entity.Email,
                Telephone = entity.Telephone
            };

            collector.Collect(entity, person);

            return(person);
        }
Exemplo n.º 2
0
        internal static EventTree Read(this EventTreeEntity 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 eventTree = new EventTree
            {
                Name               = entity.Name,
                Details            = entity.Details,
                Summary            = entity.Summary,
                MainTreeEvent      = entity.TreeEventEntity?.Read(collector),
                Color              = entity.Color.ToColor(),
                NeedsSpecification = entity.NeedsSpecification == 1
            };

            collector.Collect(entity, eventTree);

            return(eventTree);
        }
Exemplo n.º 3
0
        internal static ExpertClassEstimation Read(this ExpertClassEstimationEntity 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 estimation = new ExpertClassEstimation
            {
                Expert             = entity.ExpertEntity.Read(collector),
                HydraulicCondition = entity.HydraulicConditionElementEntity.Read(collector),
                AverageEstimation  = (ProbabilityClass)entity.AverageEstimation,
                MinEstimation      = (ProbabilityClass)entity.MinEstimation,
                MaxEstimation      = (ProbabilityClass)entity.MaxEstimation
                                     // TODO: Add Comment
            };

            collector.Collect(entity, estimation);

            return(estimation);
        }
Exemplo n.º 4
0
        internal static Expert Read(this ExpertEntity 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 person = entity.PersonEntity.Read(collector);
            var expert = new Expert
            {
                Name         = person.Name,
                Email        = person.Email,
                Telephone    = person.Telephone,
                Expertise    = entity.Expertise,
                Organisation = entity.Organisation
            };

            collector.Collect(entity, expert);
            return(expert);
        }
Exemplo n.º 5
0
        internal static HydraulicCondition Read(this HydraulicConditionElementEntity 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));
            }

            FragilityCurveElement curveElement = entity.FragilityCurveElementEntity.Read(collector);
            var condition = new HydraulicCondition
            {
                Probability = curveElement.Probability,
                WaterLevel  = curveElement.WaterLevel,
                WavePeriod  = entity.WavePeriod == null ? double.NaN : (double)entity.WavePeriod,
                WaveHeight  = entity.WaveHeight == null ? double.NaN : (double)entity.WaveHeight
            };

            collector.Collect(entity, condition);
            return(condition);
        }
        internal static TreeEvent Read(this TreeEventEntity 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 treeEvent = new TreeEvent
            {
                Name             = entity.Name,
                Details          = entity.Details,
                FixedProbability = entity.FixedProbability == null
                    ? Probability.NaN
                    : (Probability)(double)entity.FixedProbability,
                ProbabilitySpecificationType = (ProbabilitySpecificationType)entity.ProbabilitySpecificationType,
                Summary     = entity.Summary,
                Information = entity.Information,
                Discussion  = entity.Discussion
                              // TODO: Add PassPhrase
            };

            ReadFragilityCurve(treeEvent, entity.TreeEventFragilityCurveElementEntities, collector);

            if (entity.TreeEventEntity3 != null)
            {
                treeEvent.FailingEvent = entity.TreeEventEntity3.Read(collector);
            }

            if (entity.TreeEventEntity2 != null)
            {
                treeEvent.PassingEvent = entity.TreeEventEntity2.Read(collector);
            }

            ReadExpertClassSpecifications(entity, collector, treeEvent);
            collector.Collect(entity, treeEvent);
            return(treeEvent);
        }
        internal static FragilityCurveElement Read(this FragilityCurveElementEntity 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 element =
                new FragilityCurveElement(entity.WaterLevel.ToNullAsNaN(), (Probability)entity.Probability.ToNullAsNaN());

            collector.Collect(entity, element);

            return(element);
        }