public virtual IEnumerable <IObservable> UpdateSectionsWithImportedData(IEnumerable <FailureMechanismSection> importedFailureMechanismSections, string sourcePath) { if (importedFailureMechanismSections == null) { throw new ArgumentNullException(nameof(importedFailureMechanismSections)); } if (sourcePath == null) { throw new ArgumentNullException(nameof(sourcePath)); } var affectedObjects = new List <IObservable>(); try { failureMechanism.SetSections(importedFailureMechanismSections, sourcePath); affectedObjects.Add(failureMechanism); affectedObjects.Add(failureMechanism.SectionResults); } catch (ArgumentException e) { throw new UpdateDataException(e.Message, e); } return(affectedObjects); }
public virtual IEnumerable <IObservable> UpdateSectionsWithImportedData(IEnumerable <FailureMechanismSection> importedFailureMechanismSections, string sourcePath) { if (importedFailureMechanismSections == null) { throw new ArgumentNullException(nameof(importedFailureMechanismSections)); } if (sourcePath == null) { throw new ArgumentNullException(nameof(sourcePath)); } T[] oldSectionResults = failureMechanism.SectionResults.ToArray(); try { failureMechanism.SetSections(importedFailureMechanismSections, sourcePath); } catch (ArgumentException e) { throw new UpdateDataException(e.Message, e); } foreach (T sectionResult in failureMechanism.SectionResults) { T equalSection = oldSectionResults.FirstOrDefault(item => item.Section.StartPoint.Equals(sectionResult.Section.StartPoint) && item.Section.EndPoint.Equals(sectionResult.Section.EndPoint)); if (equalSection != null) { sectionResultUpdateStrategy.UpdateSectionResult(equalSection, sectionResult); } } return(new IObservable[] { failureMechanism, failureMechanism.SectionResults }); }
/// <summary> /// Sets a collection of <see cref="FailureMechanismSection"/> to <see cref="IFailureMechanism.Sections"/> /// with an empty source path. /// </summary> /// <param name="failureMechanism">The failure mechanism to set the sections to.</param> /// <param name="sections">The sections to set.</param> /// <exception cref="ArgumentNullException">Thrown when <see cref="sections"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <paramref name="sections"/> contains elements that /// are not properly connected.</exception> public static void SetSections(IFailureMechanism failureMechanism, IEnumerable <FailureMechanismSection> sections) { failureMechanism.SetSections(sections, string.Empty); }