Exemple #1
0
        protected internal override void WriteToXml(System.Xml.XmlElement xel)
        {
            xel.RemoveAll();
            XmlElement xfirst  = Write(xel, "wall.first");
            XmlElement xsecond = Write(xel, "wall.second");

            WriteAttribute(xfirst, "x", First.X.ToString());
            WriteAttribute(xfirst, "y", First.Y.ToString());
            WriteAttribute(xsecond, "x", Second.X.ToString());
            WriteAttribute(xsecond, "y", Second.Y.ToString());
        }
Exemple #2
0
        protected internal virtual void WriteSelfToXml(System.Xml.XmlElement xel)
        {
            xel.RemoveAll();
            bool isSelfContainer = (this as Container) != null;

            WriteAttribute(xel, "type", isSelfContainer ? "container" : "property");
            WriteAttribute(xel, "subtype", this.GetType().Name);
            XmlElement xn = Write(xel, "property.key");

            WriteText(xn, Key);
            xn = Write(xel, "property.name");
            WriteText(xn, Name);
            WriteCData(xel, "property.value", Value);
        }
Exemple #3
0
        protected internal override void WriteToXml(System.Xml.XmlElement xel)
        {
            xel.RemoveAll();
            XmlElement xch = Write(xel, "session.characters");

            foreach (Character c in characters)
            {
                XmlElement xc = Write(xch, "character");
                c.WriteToXml(xc);
            }
            //WriteCollection<Character>(xel, "session.characters", "character", characters);
            WriteCollection <Map>(xel, "session.maps", "map", maps);
            if (SelectedMap != null)
            {
                WriteAttribute(xel, "selectedMap", SelectedMap.Name);
            }
        }
Exemple #4
0
        protected internal override void WriteToXml(System.Xml.XmlElement xel)
        {
            xel.RemoveAll();
            WriteText(xel, Name);
            WriteAttribute(xel, "xsize", SizeX);
            WriteAttribute(xel, "ysize", SizeY);
            WriteCData(xel, "notes", Notes);
            WriteCollection <Door>(xel, "map.doors", "door", doors);
            WriteCollection <Wall>(xel, "map.walls", "wall", walls);
            WriteCollection <PointOfInterest>(xel, "map.pointofinterests", "pointofinterest", pois);
            WriteCollection <Block>(xel, "map.blocks", "block", blocks);
            WriteCollection <Effect>(xel, "map.effects", "effect", effects);

            if (Characters.Count > 0)
            {
                XmlElement xchrs = Write(xel, "map.characters");
                foreach (Character chr in Characters)
                {
                    XmlElement xc = Write(xchrs, "character");
                    WriteAttribute(xc, "code", chr.Value);
                }
            }
        }
Exemple #5
0
		// TODO:  Take the word save off front of this method when XmlNode.RemoveAll() is fully implemented.

		public void saveTestRemoveAllAffectOnEnumeration ()
		{
			document.LoadXml ("<foo><child1/><child2/><child3/></foo>");
			element = document.DocumentElement;
			enumerator = element.GetEnumerator();
			Assert.AreEqual (element.ChildNodes.Count, 3, "Expected 3 children.");
			Assert.AreEqual (enumerator.MoveNext(), true, "MoveNext should have succeeded.");
			element.RemoveAll();
			Assert.AreEqual (enumerator.MoveNext(), false, "MoveNext should have failed.");
		}
Exemple #6
0
        private void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
        {
            if (context == SaveContext.Copy || context == SaveContext.Undo)
            {
                //Dump all the information into memory

                nodeElement.SetAttribute("inputCount", InputCount.ToString());
                nodeElement.SetAttribute("outputCount", OutputCount.ToString());
                nodeElement.SetAttribute("legacyNodeName", LegacyNodeName);
                nodeElement.SetAttribute("legacyAssembly", LegacyAssembly);
                nodeElement.SetAttribute("nodeNature", NodeNature.ToString());

                if (OriginalNodeContent != null)
                {
                    XmlElement originalNode = xmlDoc.CreateElement("OriginalNodeContent");
                    XmlElement nodeContent = nodeElement.OwnerDocument.CreateElement(OriginalNodeContent.Name);

                    foreach (XmlAttribute attribute in OriginalNodeContent.Attributes)
                        nodeContent.SetAttribute(attribute.Name, attribute.Value);

                    for (int i = 0; i < OriginalNodeContent.ChildNodes.Count; i++)
                    {
                        XmlNode child =
                            nodeContent.OwnerDocument.ImportNode(OriginalNodeContent.ChildNodes[i], true);
                        nodeContent.AppendChild(child.CloneNode(true));
                    }

                    originalNode.AppendChild(nodeContent);
                    nodeElement.AppendChild(originalNode);
                }
            }

            if (context == SaveContext.File)
            {
                //When save files, only save the original node's content, 
                //instead of saving the dummy node.
                if (OriginalNodeContent != null)
                {
                    nodeElement.RemoveAll();
                    foreach (XmlAttribute attribute in OriginalNodeContent.Attributes)
                        nodeElement.SetAttribute(attribute.Name, attribute.Value);

                    //overwrite the guid/x/y value of the original node.
                    nodeElement.SetAttribute("guid", nodeElement.GetAttribute("guid"));
                    nodeElement.SetAttribute("x", nodeElement.GetAttribute("x"));
                    nodeElement.SetAttribute("y", nodeElement.GetAttribute("y"));

                    for (int i = 0; i < OriginalNodeContent.ChildNodes.Count; i++)
                    {
                        XmlNode child = nodeElement.OwnerDocument.ImportNode(OriginalNodeContent.ChildNodes[i], true);
                        nodeElement.AppendChild(child.CloneNode(true));
                    }
                }
                else
                {
                    nodeElement.SetAttribute("inputCount", InputCount.ToString());
                    nodeElement.SetAttribute("outputCount", OutputCount.ToString());
                    nodeElement.SetAttribute("legacyNodeName", LegacyNodeName);
                    nodeElement.SetAttribute("legacyAssembly", LegacyAssembly);
                    nodeElement.SetAttribute("nodeNature", NodeNature.ToString());
                }
            }
        }
Exemple #7
0
 public void RemoveElement(XmlElement ele)
 {
     ele.RemoveAll();
 }