Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
 /// <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)]));
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 public Transition(XMLEntity en, Timetable tt) : base(en, tt)
 {
 }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
 /// <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;
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 public Station(XMLEntity en, Timetable tt) : base(en, tt)
 {
     Positions.TestForErrors();
     Tracks = new ObservableChildrenCollection <Track>(this, "track", ParentTimetable);
 }
Exemplo n.º 8
0
 public ShuntMove(XMLEntity en, Timetable tt) : base(en, tt)
 {
 }
Exemplo n.º 9
0
 public Track(XMLEntity en, Timetable tt) : base(en, tt)
 {
 }