当前位置: 首页>>代码示例>>C#>>正文


C# DomNode.GetChildList方法代码示例

本文整理汇总了C#中DomNode.GetChildList方法的典型用法代码示例。如果您正苦于以下问题:C# DomNode.GetChildList方法的具体用法?C# DomNode.GetChildList怎么用?C# DomNode.GetChildList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DomNode的用法示例。


在下文中一共展示了DomNode.GetChildList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DomNode

        /// <summary>
        /// Finish MEF intialization for the component by creating DomNode tree for application data.</summary>
        void IInitializable.Initialize()
        {
            m_mainform.Shown += (sender, e) =>
                {
                    // create root node.
                    var rootNode = new DomNode(Schema.gameType.Type, Schema.gameRootElement);
                    rootNode.SetAttribute(Schema.gameType.nameAttribute, "Game");

                    // create Orc game object and add it to rootNode.
                    var orc1 = CreateOrc("Orc1");
                    rootNode.GetChildList(Schema.gameType.gameObjectChild).Add(orc1);

                    // add a child Orc.
                    var orcChildList = orc1.GetChildList(Schema.orcType.orcChild);
                    orcChildList.Add(CreateOrc("Child Orc1"));


                    var orc2 = CreateOrc("Orc2");
                    rootNode.GetChildList(Schema.gameType.gameObjectChild).Add(orc2);


                    rootNode.InitializeExtensions();


                    // set active context and select orc object.
                    m_contextRegistry.ActiveContext = rootNode;
                    
                    var selectionContext = rootNode.Cast<ISelectionContext>();
                    selectionContext.Set(new AdaptablePath<object>(orc1.GetPath()));                                       
                };
        }
开发者ID:jethac,项目名称:ATF,代码行数:33,代码来源:Editor.cs

示例2: ImportTemplates

        /// <summary>
        /// Imports templates and template folders stored in an external file</summary>
        /// <param name="toFolder">Template folder in which to import templates and template folders</param>
        /// <param name="fromRoot">Root of templates to import</param>
        /// <param name="uri"></param>
        internal void ImportTemplates(DomNode toFolder, DomNode fromRoot, Uri uri)
        {
            TagTemplateTree(fromRoot, uri);
 
            // assume all templates and their containing folders are children of a root template folder 
            foreach (var domNode in fromRoot.LevelSubtree) // add top-level folders
            {
                if (domNode.Type == Schema.templateFolderType.Type) // this should be the root template folder of the imported DOM tree
                {
                    // import the children of the root template folder, but not the root itself
                    foreach (var child in domNode.Children.ToArray())
                    {
                        if (child.Type == Schema.templateFolderType.Type)
                        {
                            toFolder.GetChildList(Schema.templateFolderType.templateFolderChild).Add(child);
                        }
                        else if (child.Type == Schema.templateType.Type)
                        {
                            toFolder.GetChildList(Schema.templateFolderType.templateChild).Add(child);
                        }
                    }
                    break; // skip the rest of the document contents
                }
            }
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:30,代码来源:CircuitReader.cs

示例3: CreateGameUsingDomNode

        /// <summary>
        /// Creates game using raw DomNode</summary>        
        private static DomNode CreateGameUsingDomNode()
        {                                     
            // create Dom node of the root type defined by the schema
            DomNode game = new DomNode(GameSchema.gameType.Type, GameSchema.gameRootElement);
            game.SetAttribute(GameSchema.gameType.nameAttribute, "Ogre Adventure II");
            IList<DomNode> childList = game.GetChildList(GameSchema.gameType.gameObjectChild);

            // Add an ogre
            DomNode ogre = new DomNode(GameSchema.ogreType.Type);
            ogre.SetAttribute(GameSchema.ogreType.nameAttribute, "Bill");
            ogre.SetAttribute(GameSchema.ogreType.sizeAttribute, 12);
            ogre.SetAttribute(GameSchema.ogreType.strengthAttribute, 100);
            childList.Add(ogre);


            // Add a dwarf
            DomNode dwarf = new DomNode(GameSchema.dwarfType.Type);
            dwarf.SetAttribute(GameSchema.dwarfType.nameAttribute, "Sally");
            dwarf.SetAttribute(GameSchema.dwarfType.ageAttribute, 32);
            dwarf.SetAttribute(GameSchema.dwarfType.experienceAttribute, 55);
            childList.Add(dwarf);

            // Add a tree
            DomNode tree = new DomNode(GameSchema.treeType.Type);
            tree.SetAttribute(GameSchema.treeType.nameAttribute, "Mr. Oak");
            childList.Add(tree);

            return game;           
        }
开发者ID:vincenthamm,项目名称:ATF,代码行数:31,代码来源:Program.cs

示例4: TestValidate

        public void TestValidate()
        {
            DomNodeType childType = new DomNodeType("child");
            DomNodeType parentType = new DomNodeType("parent");
            ChildInfo childInfo = new ChildInfo("child", childType, true);
            parentType.Define(childInfo);
            DomNode parent = new DomNode(parentType);
            IList<DomNode> childList = parent.GetChildList(childInfo);
            DomNode child1 = new DomNode(childType);
            DomNode child2 = new DomNode(childType);
            DomNode child3 = new DomNode(childType);

            ChildCountRule test = new ChildCountRule(1, 2);
            
            // 0 children. Not valid.
            Assert.False(test.Validate(parent, null, childInfo));

            // 1 child. Valid.
            childList.Add(child1);
            Assert.True(test.Validate(parent, null, childInfo));
            
            // 2 children. Valid.
            childList.Add(child2);
            Assert.True(test.Validate(parent, null, childInfo));

            // 3 children. Not valid.
            childList.Add(child3);
            Assert.False(test.Validate(parent, null, childInfo));

            // 0 children. Not valid.
            childList.Clear();
            Assert.False(test.Validate(parent, null, childInfo));
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:33,代码来源:TestChildCountRule.cs

示例5: CreateOrc

        /// <summary>
        /// Helper method to create instance of orcType.</summary>
        private static DomNode CreateOrc(string name = "Orc")
        {
            var orc = new DomNode(Schema.orcType.Type);
            orc.SetAttribute(Schema.orcType.nameAttribute, name);
            orc.SetAttribute(Schema.orcType.TextureRevDateAttribute, DateTime.Now);
            orc.SetAttribute(Schema.orcType.resourceFolderAttribute,System.Windows.Forms.Application.StartupPath);
            orc.SetAttribute(Schema.orcType.skinColorAttribute, System.Drawing.Color.DarkGray.ToArgb());
            orc.SetAttribute(Schema.orcType.healthAttribute, 80);
            var armorList = orc.GetChildList(Schema.orcType.armorChild);

            armorList.Add(CreateArmor("Iron breast plate",20,300));

            var clubList = orc.GetChildList(Schema.orcType.clubChild);
            clubList.Add(CreateClub(true, 20, 30));

            return orc;
        }
开发者ID:vincenthamm,项目名称:ATF,代码行数:19,代码来源:Editor.cs

示例6: TestChildParent

        public void TestChildParent()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type, true);
            type.Define(childInfo);

            DomNode child = new DomNode(type);
            DomNode parent = new DomNode(type);
            parent.GetChildList(childInfo).Add(child);
            Assert.AreSame(child.Parent, parent);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:11,代码来源:TestDomNode.cs

示例7: Validate

 /// <summary>
 /// Checks that the parent DomNode has the correct # of children of the given type</summary>
 /// <param name="parent">Parent DOM node</param>
 /// <param name="child">Child DOM node; ignored</param>
 /// <param name="childInfo">Child relationship info</param>
 /// <returns>True, iff 'parent' has a valid number of children of the type associated
 /// with 'childInfo'</returns>
 public override bool Validate(DomNode parent, DomNode child, ChildInfo childInfo)
 {
     if (childInfo.IsList)
     {
         IList<DomNode> childList = parent.GetChildList(childInfo);
         int count = childList.Count;
         return
             count >= m_min &&
             count <= m_max;
     }
     // singleton child references can always be set
     return true;
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:20,代码来源:ChildCountRule.cs

示例8: TestDescendantGetRoot

        public void TestDescendantGetRoot()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type, true);
            type.Define(childInfo);

            DomNode child = new DomNode(type);
            DomNode parent = new DomNode(type);
            DomNode grandparent = new DomNode(type);
            parent.GetChildList(childInfo).Add(child);
            grandparent.GetChildList(childInfo).Add(parent);
            Assert.AreSame(child.GetRoot(), grandparent);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:13,代码来源:TestDomNode.cs

示例9: WriteElement

 /// <summary>
 /// Writes the element corresponding to the node</summary>
 /// <param name="node">DomNode to write</param>
 /// <param name="writer">The XML writer. See <see cref="T:System.Xml.XmlWriter"/></param>
 protected override void WriteElement(DomNode node, XmlWriter writer)
 {
     if (node.Type == Schema.prefabInstanceType.Type)
     {
         WriteStartElement(node, writer);
         WriteAttributes(node, writer);
         foreach (DomNode child in node.GetChildList(Schema.prefabInstanceType.objectOverrideChild))
             WriteElement(child, writer);
         writer.WriteEndElement();
     }
     else
     {
         base.WriteElement(node, writer);
     }
 }
开发者ID:BeRo1985,项目名称:LevelEditor,代码行数:19,代码来源:CustomDomXmlWriter.cs

示例10: TestGetPath

        public void TestGetPath()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type, true);
            type.Define(childInfo);

            DomNode child = new DomNode(type);
            DomNode parent = new DomNode(type);
            DomNode grandparent = new DomNode(type);
            parent.GetChildList(childInfo).Add(child);
            grandparent.GetChildList(childInfo).Add(parent);

            Utilities.TestSequenceEqual(child.GetPath(), grandparent, parent, child);
            Utilities.TestSequenceEqual(parent.GetPath(), grandparent, parent);
            Utilities.TestSequenceEqual(grandparent.GetPath(), grandparent);
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:16,代码来源:TestDomNode.cs

示例11: Read

        /// <summary>
        /// Reads in the data for an EventSequenceDocument from the given stream</summary>
        /// <remarks>This method proves the concept that a document can be persisted in a custom
        /// file format that is not XML.</remarks>
        /// <param name="stream">Stream with event sequence data</param>
        /// <returns>A valid EventSequenceDocument if successful or null if the stream's data is invalid</returns>
        public static EventSequenceDocument Read(Stream stream)
        {
            using (StreamReader reader = new StreamReader(stream))
            {
                string line = reader.ReadLine();
                if (line != "eventSequence")
                    return null;

                DomNode root = new DomNode(DomTypes.eventSequenceType.Type, DomTypes.eventSequenceRootElement);
                bool readLineForEvent = true;
                while (true)
                {
                    // The root has a sequence of children that are eventType nodes.
                    if (readLineForEvent)
                        line = reader.ReadLine();
                    if (string.IsNullOrEmpty(line))
                        break;
                    readLineForEvent = true;
                    DomNode eventNode;
                    if (!ReadEvent(line, out eventNode))
                        break;
                    root.GetChildList(DomTypes.eventSequenceType.eventChild).Add(eventNode);

                    // Each eventType node may have zero or more resourceType nodes.
                    while (true)
                    {
                        line = reader.ReadLine();
                        if (string.IsNullOrEmpty(line))
                            break;
                        DomNode resourceNode;
                        if (!ReadResource(line, out resourceNode))
                        {
                            // might be a line for an event
                            readLineForEvent = false;
                            break;
                        }
                        eventNode.GetChildList(DomTypes.eventType.resourceChild).Add(resourceNode);
                    }
                }

                return root.Cast<EventSequenceDocument>();
            }
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:49,代码来源:EventSequenceDocument.cs

示例12: Insert

        public void Insert(DomNode parent, DomNode child, ChildInfo chInfo, int index)
        {
            NativeObjectAdapter childObject = child.As<NativeObjectAdapter>();
            NativeObjectAdapter parentObject = parent.As<NativeObjectAdapter>();

            object listIdObj = chInfo.GetTag(NativeAnnotations.NativeElement);

            if (childObject == null || parentObject == null || listIdObj == null)
                return;

            if (chInfo.IsList && index >= (parent.GetChildList(chInfo).Count - 1))
                index = -1;

            if (ManageNativeObjectLifeTime)
            {
                GameEngine.CreateObject(childObject);
                childObject.UpdateNativeOjbect();
            }
            System.Diagnostics.Debug.Assert(childObject.InstanceId != 0);

            uint listId = (uint)listIdObj;
            uint typeId = (uint)chInfo.DefiningType.GetTag(NativeAnnotations.NativeType);
            ulong parentId = parentObject.InstanceId;
            ulong childId = childObject.InstanceId;

            if (index >= 0)
            {
                GameEngine.ObjectInsertChild(typeId, listId, parentId, childId, index);
            }
            else
            {
                GameEngine.ObjectAddChild(typeId, listId, parentId, childId);
            }

            foreach (var node in child.Children)
            {
                Insert(child, node, node.ChildInfo, -1); // use -1 for index to indicate an append operation.
            }
        }    
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:39,代码来源:NativeGameWorldAdapter.cs

示例13: TestCopy_MultipleNodes

        public void TestCopy_MultipleNodes()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo info = new ChildInfo("child", type);
            ChildInfo infoList = new ChildInfo("childList", type, true);
            type.Define(info);
            type.Define(infoList);
            ChildInfo rootInfo = new ChildInfo("root", type, true);
            DomNode test = new DomNode(type, rootInfo);
            DomNode child1 = new DomNode(type);
            test.SetChild(info, child1);
            DomNode child2 = new DomNode(type);
            DomNode child3 = new DomNode(type);
            IList<DomNode> list = test.GetChildList(infoList);
            list.Add(child2);
            list.Add(child3);

            DomNode[] result = DomNode.Copy(new DomNode[] { test });
            Assert.AreEqual(result.Length, 1);
            Assert.True(Equals(result[0], test));

            DomNode singleResult = DomNode.Copy(test);
            Assert.True(Equals(singleResult, test));
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:24,代码来源:TestDomNode.cs

示例14: TestChildRemoveEvents

        public void TestChildRemoveEvents()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo info = new ChildInfo("child", type);
            ChildInfo infoList = new ChildInfo("childList", type, true);
            type.Define(info);
            type.Define(infoList);
            DomNode test = new DomNode(type);
            test.ChildRemoving += new EventHandler<ChildEventArgs>(test_ChildRemoving);
            test.ChildRemoved += new EventHandler<ChildEventArgs>(test_ChildRemoved);

            // test child
            DomNode child = new DomNode(type);
            test.SetChild(info, child);
            ChildRemovingArgs = null;
            ChildRemovedArgs = null;
            test.SetChild(info, null);
            ChildEventArgs expected = new ChildEventArgs(test, info, child, 0);
            Assert.True(Equals(ChildRemovingArgs, expected));
            Assert.True(Equals(ChildRemovedArgs, expected));

            // test inserting a child when there is one there already
            test.SetChild(info, child);
            DomNode newChild = new DomNode(type);
            ChildRemovingArgs = null;
            ChildRemovedArgs = null;
            test.SetChild(info, newChild);
            expected = new ChildEventArgs(test, info, child, 0);
            Assert.True(Equals(ChildRemovingArgs, expected));
            Assert.True(Equals(ChildRemovedArgs, expected));

            // test child list
            IList<DomNode> list = test.GetChildList(infoList);
            DomNode child2 = new DomNode(type);
            list.Add(child2);
            DomNode child3 = new DomNode(type);
            list.Add(child3);
            ChildRemovingArgs = null;
            ChildRemovedArgs = null;
            list.Remove(child3);
            expected = new ChildEventArgs(test, infoList, child3, 1);
            Assert.True(Equals(ChildRemovingArgs, expected));
            Assert.True(Equals(ChildRemovedArgs, expected));
            ChildRemovingArgs = null;
            ChildRemovedArgs = null;
            list.Remove(child2);
            expected = new ChildEventArgs(test, infoList, child2, 0);
            Assert.True(Equals(ChildRemovingArgs, expected));
            Assert.True(Equals(ChildRemovedArgs, expected));
        }
开发者ID:cococo111111,项目名称:ATF,代码行数:50,代码来源:TestDomNode.cs

示例15: TestRemoveFromParentList

 public void TestRemoveFromParentList()
 {
     DomNodeType type = new DomNodeType("type");
     ChildInfo childInfo = new ChildInfo("child", type, true);
     type.Define(childInfo);
     DomNode parent = new DomNode(type);
     DomNode child = new DomNode(type);
     parent.GetChildList(childInfo).Add(child);
     child.RemoveFromParent();
     CollectionAssert.IsEmpty(parent.Children);
     Assert.Null(child.Parent);
 }
开发者ID:cococo111111,项目名称:ATF,代码行数:12,代码来源:TestDomNode.cs


注:本文中的DomNode.GetChildList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。