public void ReadXml(XmlReader reader) { reader.MoveToContent(); Source = reader["Source"]; if (reader.IsEmptyElement) { reader.ReadStartElement(); return; } reader.ReadStartElement(); while (!reader.EOF) { if (reader.IsStartElement()) { switch (reader.Name) { case "Sprite": XmlSpriteElement sprite = new XmlSpriteElement(); sprite.ReadXml(reader); Sprites.Add(sprite); break; default: reader.Skip(); break; } } else if (reader.NodeType == XmlNodeType.EndElement) { reader.ReadEndElement(); break; } else reader.Read(); } }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("Source", Source); foreach (ISpriteElement sprite in Sprites) { XmlSpriteElement elem = sprite as XmlSpriteElement; if (elem == null) elem = new XmlSpriteElement(sprite); writer.WriteStartElement("Sprite"); elem.WriteXml(writer); writer.WriteEndElement(); } }