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 Project Read(this ProjectEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } var experts = entity.ExpertEntities.OrderBy(e => e.Order).Select(e => e.Read(collector)); var hydraulicConditions = entity.HydraulicConditionElementEntities.OrderBy(e => e.Order).Select(e => e.Read(collector)); var eventTrees = entity.EventTreeEntities.OrderBy(e => e.Order).Select(e => e.Read(collector)); var project = new Project { Name = entity.Name, AssessmentSection = entity.AssessmentSection, Description = entity.Description, ProjectInformation = entity.ProjectInformation, ProjectLeader = entity.PersonEntity.Read(collector), StartDate = DateTime.Parse(entity.StartDate, CultureInfo.InvariantCulture.DateTimeFormat), EndDate = DateTime.Parse(entity.EndDate, CultureInfo.InvariantCulture.DateTimeFormat) }; foreach (var expert in experts) { project.Experts.Add(expert); } foreach (var hydraulicCondition in hydraulicConditions) { project.HydraulicConditions.Add(hydraulicCondition); } foreach (var eventTree in eventTrees) { project.EventTrees.Add(eventTree); } return(project); }
private static void ReadFragilityCurve(TreeEvent treeEvent, IEnumerable <TreeEventFragilityCurveElementEntity> entities, ReadConversionCollector collector) { foreach (var treeEventFragilityCurveElementEntity in entities.OrderBy(e => e.Order)) { treeEvent.FixedFragilityCurve.Add(treeEventFragilityCurveElementEntity.Read(collector)); } }
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); }
internal static FragilityCurveElement Read(this TreeEventFragilityCurveElementEntity entity, ReadConversionCollector collector) { return(entity.FragilityCurveElementEntity.Read(collector)); }
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); }