public static LineShape Load(XmlReader reader) { LineShape line = new LineShape(); line.Start = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("start")); line.End = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("end")); return(line); }
public static Waypoint Load(XmlReader reader) { Waypoint shape = new Waypoint(); LoadPositionalData(shape, reader); shape.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position")); return(shape); }
public static CircleShape Load(XmlReader reader) { CircleShape circle = new CircleShape(); circle.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position")); circle.Radius = reader.GetDoubleAttribute("radius"); return(circle); }
public static PointObservation Load(XmlReader reader, Dictionary <Observation, string> observers) { PointObservation shape = new PointObservation(); LoadPositionalData(shape, reader); shape.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position")); observers.Add(shape, reader.GetAttribute("observer")); return(shape); }
public static new UnitShape Load(XmlReader reader, Dictionary <Observation, string> observers, Dictionary <string, UnitShape> unitsById) { UnitShape shape = new UnitShape(); shape.Name = reader.GetAttribute("name"); shape.Position = ManeuveringBoard.ParseXmlPoint(reader.GetStringAttribute("position")); shape.Direction = reader.GetDoubleAttribute("course"); shape.Speed = reader.GetDoubleAttribute("speed"); shape.Type = Utility.ParseEnum <UnitShapeType>(reader.GetStringAttribute("type", "unknown"), true); string id = reader.GetAttribute("id"); if (!string.IsNullOrEmpty(id)) { unitsById.Add(id, shape); } if (!reader.IsEmptyElement) { reader.Read(); while (reader.NodeType == XmlNodeType.Element) { if (reader.LocalName == "tmaSolution") { shape.TMASolution = TMASolution.Load(reader); } else if (reader.LocalName == "children" && !reader.IsEmptyElement) { reader.Read(); // move to either the first child or the end element while (reader.NodeType == XmlNodeType.Element) { shape.Children.Add(Shape.Load(reader, observers, unitsById)); } reader.ReadEndElement(); } else { throw new InvalidDataException("Expected element " + reader.LocalName); } } } return(shape); }