private void ReadDirectionsXml(XmlReader reader)
        {
            reader.MoveToContent();
            if (reader.IsEmptyElement) {
                reader.ReadStartElement();
                return;
            }

            reader.ReadStartElement();
            while (!reader.EOF) {
                if (reader.IsStartElement()) {
                    switch (reader.Name) {
                        case "Direction":
                            XmlDirectionElement direction = new XmlDirectionElement();
                            direction.ReadXml(reader);
                            Directions.Add(direction);
                            break;

                        default:
                            reader.Skip();
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement) {
                    reader.ReadEndElement();
                    break;
                }
                else
                    reader.Read();
            }
        }
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteAttributeString("Name", Name);

            writer.WriteStartElement("Directions");

            foreach (IDirectionElement direction in Directions) {
                XmlDirectionElement elem = direction as XmlDirectionElement;
                if (elem == null)
                    elem = new XmlDirectionElement(direction);

                writer.WriteStartElement("Direction");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            writer.WriteEndElement();
        }
        public void WriteXml(XmlWriter writer)
        {
            if (Instance != null) {
                XmlDirectionalAnimatedSpriteInstance elem = Instance as XmlDirectionalAnimatedSpriteInstance;
                if (elem == null)
                    elem = new XmlDirectionalAnimatedSpriteInstance(Instance);

                writer.WriteStartElement("Instance");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (Sprites != null) {
                XmlSpriteListElement elem = Sprites as XmlSpriteListElement;
                if (elem == null)
                    elem = new XmlSpriteListElement(Sprites);

                writer.WriteStartElement("Sprites");
                elem.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (Directions != null) {
                writer.WriteStartElement("Directions");

                foreach (IDirectionElement direction in Directions) {
                    XmlDirectionElement elem = direction as XmlDirectionElement;
                    if (elem == null)
                        elem = new XmlDirectionElement(direction);

                    writer.WriteStartElement("Direction");
                    elem.WriteXml(writer);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }
        }