AddChild() 공개 메소드

public AddChild ( DataNode, node ) : void
node DataNode,
리턴 void
예제 #1
0
        public DataNode CollectPipeData()
        {
            var data = new DataNode(new PipeString("This is my test message that I am sending over."));

            data.AddChild(new DataNode(new PipeNumber(2.56)));;
            data.ChildrenList[0].AddChild(new DataNode(new PipeInteger(2)));
            data.ChildrenList[0].AddChild(new DataNode(new PipeInteger(3)));
            data.AddChild(new DataNode(new PipeNumber(3.14)));
            data.ChildrenList[1].AddChild(new DataNode(new PipeString("Does this work ?")));
            return(data);
        }
예제 #2
0
    public DataNode Save()
    {
        DataNode node = new DataNode();

        node.Name = "Player";

        var t_node = node.AddChild("team");

        for (int i = 0; i < team.ToArray().Length; i++)
        {
            var spirit = team.ToArray()[i];
            var c      = t_node.AddChild(spirit.Name + "_" + i);

            c.AddChild("Type", spirit.Type.Name);

            c.AddChild("Level", spirit.Level);
            c.AddChild("EP", spirit.expierience);
            c.AddChild("HP", spirit.HP);
            c.AddChild("DMG", spirit.DMG);
            c.AddChild("DEF", spirit.DEF);
            c.AddChild("SPEED", spirit.SPEED);
            c.AddChild("ACC", spirit.ACC);
            c.AddChild("CRIT", spirit.CRIT);
            c.AddChild("Name", spirit.Name);
            c.AddChild("CurrentHP", spirit.CurrentHP);

            var a_node = c.AddChild("Attack");

            foreach (var attack in spirit.Attacks)
            {
                var a = a_node.AddChild("" + spirit.Attacks.IndexOf(attack));
                a.AddChild("Name", attack.Name);
                a.AddChild("Type", (int)attack.Type);
                a.AddChild("Accuracy", attack.Accuracy);
                a.AddChild("AttackName", (int)attack.AttackName);
                a.AddChild("BaseDMG", attack.BaseDMG);
                a.AddChild("StaminaCost", attack.StaminaCost);
            }
        }

        var i_node = node.AddChild("items");
        var items  = Items.GetElements();

        for (int i = 0; i < items.Count; ++i)
        {
            i_node.AddChild(items[i].Name, items[i].Amount);
        }

        return(node);
    }
예제 #3
0
        public void TestReadWriteDocument()
        {
            DataNode root = new DataNode("root");

            root//.AddChild(new StringNode("wee!"))
            .AddChild(
                new DataNode("child")
                .AddChild("String data!")
                )
            .AddChild(
                new DataNode("child2")
                .AddChild(
                    new DataNode("child3")
                    .AddChild("nesting!")
                    .AddChild("This is so hot.")
                    )
                )
            .AddChild(new DataNode("empty-child"))
            .AddChild("YOU CAN'T DO THIS ON TV (or can you?!?!?!?!)")
            .AddChild("FEEL THE BURN");
            ;

            StringBuilder sb = new StringBuilder();
            StringWriter  sw = new StringWriter(sb);

            root.Write(sw);

            StringReader sr = new StringReader(sb.ToString());
            DataNode     n  = Node.ReadDocument(sr);

            Assert.AreEqual(root.Children.Count, n.GetChild("root").Children.Count);
            Assert.AreEqual(root.GetString(), n.GetChild("root").GetString());
        }
예제 #4
0
        public void TestGetChild()
        {
            DataNode child1 = new DataNode("child1");
            DataNode child2 = new DataNode("child2");

            node.AddChild(child1).AddChild(child2);

            Assert.AreSame(child1, node.GetChild("child1"));
            Assert.AreSame(child2, node.GetChild("child2"));
            Assert.IsNull(node.GetChild("does_not_exist", null));

            try {
                node.GetChild("does_not_exist");
                Assert.Fail("Node.GetChild(\"does_not_exist\") expected to raise an exception");
            } catch (Exception) {
                // no-op
            }
        }
예제 #5
0
        public DataNode Save()
        {
            DataNode node = new DataNode();

            node.Name = "MoveComponent";

            var facing = node.AddChild("FacingDirection");

            facing.AddChild("x", FacingDirection.x);
            facing.AddChild("y", FacingDirection.y);

            var pos = node.AddChild("Position");

            pos.AddChild("x", position.x);
            pos.AddChild("y", position.y);

            return(node);
        }
예제 #6
0
        public DataNode CollectPipeData()
        {
            DataNode node = new DataNode();

            for (int i = 0; i < _pipeData.Count; i++)
            {
                node.AddChild(new DataNode(GHPipeConverter.ToPipe(_pipeData[i])));
            }
            return(node);
        }
예제 #7
0
        public DataNode CollectPipeData()
        {
            DataNode node = new DataNode();

            foreach (var obj in _objectsToSend)
            {
                node.AddChild(new DataNode(PipeConverter.ToPipe(obj.Geometry)));
            }
            return(node);
        }
예제 #8
0
        public DataNode CollectPipeData()
        {
            DataNode node = new DataNode();

            foreach (var geom in _selectedObjects)
            {
                node.AddChild(new DataNode(PipeForRevit.ConvertToPipe(geom)));
            }
            return(node);
        }
예제 #9
0
        public DataNode CollectPipeData()
        {
            //convert the _data object and return it
            if (Data == null)
            {
                return(null);
            }
            DataNode node = new DataNode();

            node.AddChild(new DataNode(_converter.ToPipe <object, IPipeMemberType>(Data)));
            return(node);
        }
예제 #10
0
    public DataNode Save()
    {
        DataNode node = new DataNode();

        node.Name = "Game";

        node.AddChild("Time", GameTime.Time);
        node.AddChild("Scene", currentScene);

        var n1 = node.AddChild("Quest1Status");

        n1.AddChild("FestivalAktive", QuestPart1Variables.FestivalAktive);
        n1.AddChild("FestivalEnded", QuestPart1Variables.FestivalEnded);
        n1.AddChild("SendToSarim", QuestPart1Variables.SendToSarim);
        n1.AddChild("SendToRato", QuestPart1Variables.SendToRato);
        n1.AddChild("BanditsAppeared", QuestPart1Variables.BanditsAppeared);
        n1.AddChild("BanditsDefeated", QuestPart1Variables.BanditsDefeated);
        n1.AddChild("FestivalListened", QuestPart1Variables.FestivalListened);
        n1.AddChild("SendToExtractor", QuestPart1Variables.SendToExtractor);

        return(node);
    }
예제 #11
0
        internal DataNode ConvertListToDataNode(IList <object> listData)
        {
            if (listData == null)
            {
                return(null);
            }
            DataNode node = new DataNode();

            foreach (var obj in listData)
            {
                if (obj is IList <object> )
                {
                    node.AddChild(ConvertListToDataNode(obj as IList <object>));
                }
                else
                {
                    node.AddChild(new DataNode(_converter.ToPipe <object, IPipeMemberType>(obj)));
                }
            }

            return(node);
        }
예제 #12
0
        public DataNode CollectPipeData()
        {
            //convert the _data object and return it
            if (Data == null)
            {
                return(null);
            }
            DataNode node;

            if (Data is IList <object> )
            {
                node = ConvertListToDataNode(Data as IList <object>);
            }
            else
            {
                node = new DataNode();
                node.AddChild(new DataNode(_converter.ToPipe <object, IPipeMemberType>(Data)));
            }
            return(node);
        }
예제 #13
0
    static internal void ExportD()
    {
        var go   = Selection.activeGameObject;
        var path = UnityEditorExtensions.ShowExportDialog("Export AssetBundle", go.name);

        if (!string.IsNullOrEmpty(path))
        {
            var node      = new DataNode(go.name, go.GetInstanceID());
            var selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);

            if (BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path,
                                               BuildAssetBundleOptions.CollectDependencies |
                                               BuildAssetBundleOptions.CompleteAssets,
                                               BuildTarget.StandaloneWindows))
            {
                node.AddChild("assetBundle", System.IO.File.ReadAllBytes(path));
                Save(node, path, DataNode.SaveType.Binary);
            }
        }
    }
예제 #14
0
	// Recursive Function
	public static void ReadNode (XmlNode xmlNode, ref DataNode dataWriteNode) {
		dataWriteNode.Value = 
			xmlNode.Value == null ?
			getLeadingTag(xmlNode) :
			xmlNode.Value.Trim();
		
		if (xmlNode.HasChildNodes) {

			foreach (XmlNode childXMLNode in xmlNode.ChildNodes) {

				DataNode newDataNode = new DataNode("");

				dataWriteNode.AddChild (newDataNode);

				ReadNode(
					childXMLNode,
					ref newDataNode
				);
			}
		}
	}
예제 #15
0
        public unsafe void Save(System.IO.TextWriter stream)
        {
            DataNode rootNode = new DataNode("ika-sprite");

            rootNode.AddChild(new DataNode("version").AddChild(SPRITE_VER));

            DataNode infoNode = new DataNode("information");

            rootNode.AddChild(infoNode);
            infoNode.AddChild(new DataNode("title").AddChild("Untitled"));

            DataNode metaNode = new DataNode("meta");

            infoNode.AddChild(metaNode);

            foreach (DictionaryEntry iter in Metadata)
            {
                metaNode.AddChild(new DataNode((string)iter.Key).AddChild((string)iter.Value));
            }

            rootNode.AddChild(new DataNode("header")
                              .AddChild(new DataNode("depth").AddChild("32"))
                              );


            DataNode scriptNode = new DataNode("scripts");

            rootNode.AddChild(scriptNode);

            foreach (DictionaryEntry iter in Scripts)
            {
                scriptNode.AddChild(
                    new DataNode("script").AddChild(
                        new DataNode("label").AddChild((string)iter.Key)
                        )
                    .AddChild((string)iter.Value)
                    );
            }

            DataNode frameNode = new DataNode("frames");

            rootNode.AddChild(frameNode);

            frameNode
            .AddChild(new DataNode("count").AddChild(frames.Count))
            .AddChild(new DataNode("dimensions")
                      .AddChild(new DataNode("width").AddChild(Size.Width))
                      .AddChild(new DataNode("height").AddChild(Size.Height))
                      )
            .AddChild(new DataNode("hotspot")
                      .AddChild(new DataNode("x").AddChild(HotSpot.X))
                      .AddChild(new DataNode("y").AddChild(HotSpot.Y))
                      .AddChild(new DataNode("width").AddChild(HotSpot.Width))
                      .AddChild(new DataNode("height").AddChild(HotSpot.Height))
                      );

            MemoryStream data = new MemoryStream();

            foreach (Bitmap bmp in Frames)
            {
                BitmapData bd = bmp.LockBits(
                    Rectangle.FromLTRB(0, 0, bmp.Width, bmp.Height),
                    ImageLockMode.ReadOnly,
                    PixelFormat.Format32bppArgb
                    );

                int   numPixels = bmp.Width * bmp.Height;
                byte *b         = (byte *)bd.Scan0;
                for (int i = 0; i < numPixels; i++)
                {
                    // Swap red and blue
                    data.WriteByte(b[2]);
                    data.WriteByte(b[1]);
                    data.WriteByte(b[0]);
                    data.WriteByte(b[3]);

                    b += 4;
                }

                bmp.UnlockBits(bd);
            }

            MemoryStream         cdata = new MemoryStream();
            DeflaterOutputStream dos   = new DeflaterOutputStream(cdata);

            dos.Write(data.GetBuffer(), 0, (int)data.Position);

            dos.Finish();

            string cdata64 = Convert.ToBase64String(cdata.GetBuffer(), 0, (int)cdata.Length);

            data.Close();
            dos.Close();

            frameNode.AddChild(
                new DataNode("data")
                .AddChild(new DataNode("format").AddChild("zlib"))
                .AddChild(cdata64)
                );

            rootNode.Write(stream);
        }