/// <summary> /// Create a copy of this XML entities' XML tree. /// </summary> public XMLEntity XClone() { var clone = new XMLEntity(XName); foreach (var attr in Attributes) clone.SetAttribute(attr.Key, attr.Value); foreach (var child in Children) clone.Children.Add(child.XClone()); return clone; }
/// <summary> /// Returns if this entity is different on the top level or any child level, from the given other entity. This is a deep-compare operation. /// </summary> /// <returns>True, if both XMLentities are "equal".</returns> public bool XDiff(XMLEntity other) { if (XName != other.XName) return false; if (Value != other.Value) return false; if (Attributes.Count != other.Attributes.Count) return false; if (Attributes.Any(a => a.Value != other.GetAttribute<string>(a.Key))) return false; if (Children.Count != other.Children.Count) return false; return Children.All(c => c.XDiff(other.Children[Children.IndexOf(c)])); }
public XMLEntity(XElement el) { if (el.Name.Namespace != XNamespace.None) throw new NotSupportedException("Files witth XML namespaces are not supported!"); XName = el.Name.LocalName; if (el.Attributes().Any(a => a.Name.Namespace != XNamespace.None)) throw new NotSupportedException("Files witth XML namespaces are not supported!"); Attributes = el.Attributes().ToDictionary(a => a.Name.LocalName, a => (string)a); Value = el.Nodes().OfType<XText>().FirstOrDefault()?.Value; children = new ObservableCollection<XMLEntity>(); foreach (var c in el.Nodes().OfType<XElement>()) { var xEntity = new XMLEntity(c); xEntity.ParentElement = this; children.Add(xEntity); } children.CollectionChanged += ChildrenOnCollectionChanged; }
public Transition(XMLEntity en, Timetable tt) : base(en, tt) { }
public StationsList(XMLEntity en) : base(en, null) // Root without parent { Stations = Children.Where(x => x.XName == "sta") // Filtert andere Elemente .Select(x => new Station(x, null)) .ToList().AsReadOnly(); }
/// <summary> /// Create a new linked train instance, based on an existing xml structure. /// </summary> /// <param name="link">Parent link object.</param> /// <param name="countingIndex">The counting index of this train, relative to <paramref name="link"/>.</param> /// <param name="entity">The pre-existing xml structure.</param> public LinkedTrain(TrainLink link, int countingIndex, XMLEntity entity) : base(entity, link.ParentTimetable) { this.link = link; this.countingIndex = countingIndex; baseTrain = link.ParentTrain; }
/// <inheritdoc /> public Station(XMLEntity en, Timetable tt) : base(en, tt) { Positions.TestForErrors(); Tracks = new ObservableChildrenCollection <Track>(this, "track", ParentTimetable); }
public ShuntMove(XMLEntity en, Timetable tt) : base(en, tt) { }
public Track(XMLEntity en, Timetable tt) : base(en, tt) { }