Example #1
0
 private static void WriteRectangleXml(XmlWriter writer, RectangleInfo rectInfo)
 {
     writer.WriteStartElement("Rectangle");
     writer.WriteElementString("Name", rectInfo.Name.ToString());
     writer.WriteElementString("X", rectInfo.X.ToString());
     writer.WriteElementString("Y", rectInfo.Y.ToString());
     writer.WriteElementString("Width", rectInfo.Width.ToString());
     writer.WriteElementString("Height", rectInfo.Height.ToString());
     WriteColorXml(writer, rectInfo.Color);
     writer.WriteEndElement();
 }
 private static void WriteRectangleXml(XmlWriter writer, RectangleInfo rectInfo)
 {
     writer.WriteStartElement("Rectangle");
     writer.WriteElementString("Name", rectInfo.Name.ToString());
     writer.WriteElementString("X", rectInfo.X.ToString());
     writer.WriteElementString("Y", rectInfo.Y.ToString());
     writer.WriteElementString("Width", rectInfo.Width.ToString());
     writer.WriteElementString("Height", rectInfo.Height.ToString());
     WriteColorXml(writer, rectInfo.Color);
     writer.WriteEndElement();
 }
Example #3
0
        private static RectangleInfo ReadRectangleXml(XmlReader reader)
        {
            RectangleInfo rectInfo = new RectangleInfo();

            // Read <Rectangle>
            reader.ReadStartElement("Rectangle");
            reader.MoveToContent();
            rectInfo.Name = reader.ReadElementContentAsString("Name", "");
            reader.MoveToContent();
            rectInfo.X = reader.ReadElementContentAsInt("X", "");
            reader.MoveToContent();
            rectInfo.Y = reader.ReadElementContentAsInt("Y", "");
            reader.MoveToContent();
            rectInfo.Width = reader.ReadElementContentAsInt("Width", "");
            reader.MoveToContent();
            rectInfo.Height = reader.ReadElementContentAsInt("Height", "");
            reader.MoveToContent();
            rectInfo.Color = ReadColorXml(reader);
            reader.ReadEndElement();
            reader.MoveToContent();

            return(rectInfo);
        }
Example #4
0
        private static List <RectangleInfo> ReadRectanglesXml(XmlReader reader)
        {
            List <RectangleInfo> list = new List <RectangleInfo>();

            // Read <Rectangles>
            reader.ReadStartElement(rectanglesAtom);
            reader.MoveToContent();

            while (true)
            {
                if (String.ReferenceEquals(reader.Name, rectanglesAtom))
                {
                    reader.ReadEndElement();
                    reader.MoveToContent();
                    break;
                }

                RectangleInfo rectInfo = ReadRectangleXml(reader);

                list.Add(rectInfo);
            }

            return(list);
        }
        private static RectangleInfo ReadRectangleXml(XmlReader reader)
        {
            RectangleInfo rectInfo = new RectangleInfo();

            // Read <Rectangle>
            reader.ReadStartElement("Rectangle");
            reader.MoveToContent();
            rectInfo.Name = reader.ReadElementContentAsString("Name", "");
            reader.MoveToContent();
            rectInfo.X = reader.ReadElementContentAsInt("X", "");
            reader.MoveToContent();
            rectInfo.Y = reader.ReadElementContentAsInt("Y", "");
            reader.MoveToContent();
            rectInfo.Width = reader.ReadElementContentAsInt("Width", "");
            reader.MoveToContent();
            rectInfo.Height = reader.ReadElementContentAsInt("Height", "");
            reader.MoveToContent();
            rectInfo.Color = ReadColorXml(reader);
            reader.ReadEndElement();
            reader.MoveToContent();

            return rectInfo;
        }