Пример #1
0
        public void FromXml(XmlReader r)
        {
            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Whitespace)
                {
                    continue;
                }
                r.MoveToElement(); //Moves the reader back to the element node.
                // look for the start of an element
                if (r.NodeType == XmlNodeType.Element)
                {
                    // parse that element
                    // save the name of the element
                    string elementName = r.Name;
                    switch (elementName)
                    {
                    case "Start":
                        start = XmlHelperClass.ParseVectorAttributes(r);
                        break;

                    case "End":
                        end = XmlHelperClass.ParseVectorAttributes(r);
                        break;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
            }
        }
Пример #2
0
        public void FromXml(XmlReader r)
        {
            corners = new Vector3[4];
            int cornerNumber = 0;

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Whitespace)
                {
                    continue;
                }
                for (int i = 0; i < r.AttributeCount; i++)
                {
                    r.MoveToAttribute(i);

                    // set the field in this object based on the element we just read
                    if (r.Name == "kind")
                    {
                        kind = PolygonKindFromString(r.Value);
                        break;
                    }
                    if (r.Name == "index")
                    {
                        index = int.Parse(r.Value);
                        break;
                    }
                }
                r.MoveToElement(); //Moves the reader back to the element node.
                // look for the start of an element
                if (r.NodeType == XmlNodeType.Element)
                {
                    // parse that element
                    // save the name of the element
                    string elementName = r.Name;
                    switch (elementName)
                    {
                    case "Corner":
                        corners[cornerNumber++] = XmlHelperClass.ParseVectorAttributes(r);
                        break;
                    }
                }
                else if (r.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }
            }
        }