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


C# XmlElement.GetNotEmptyChild方法代码示例

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


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

示例1: LoadAttachments

        private void LoadAttachments(XmlElement xml)
        {
            var root = xml.GetNotEmptyChild(SpawnItemAttachmentRootName);

            foreach (XmlElement elemType in root.GetChildElements())
            {
                string type = elemType.Name;
                if (AttachmentTypes.ContainsKey(type))
                    throw new LevelXmlException("\"{0}\" contains multiple \"{1}\" elements", SpawnItemAttachmentRootName, type);

                var attachmentNames = new Dictionary<string, string>();
                AttachmentTypes[type] = attachmentNames;
                foreach (var elemName in elemType.GetChildElements())
                {
                    string name = elemName.Name;
                    string imageFileName = null;

            #if LEVEL_EDITOR
                    if (attachmentNames.ContainsKey(name))
                        throw new LevelXmlException("Multiple \"{0}\" of type \"{1}\" have the same name \"{2}\"", SpawnItemAttachmentRootName, type, name);

                    imageFileName = elemName.GetStringAttribute("Image");
            #endif
                    attachmentNames.Add(name, imageFileName);
                }
            }
        }
开发者ID:DieselPuppet,项目名称:DatingDash,代码行数:27,代码来源:SpawnItemConfig.cs

示例2: LoadTypes

        private void LoadTypes(XmlElement xml)
        {
            var root = xml.GetNotEmptyChild(SpawnItemRootName);
            foreach (XmlElement elemType in root.GetChildElements())
            {
                string type = elemType.Name;
                string imageFileName = null;

            #if LEVEL_EDITOR
                if (Types.ContainsKey(type))
                    throw new LevelXmlException("Multiple \"{0}\" have the same type \"{1}\"", SpawnItemRootName, type);

                imageFileName = elemType.GetStringAttribute("Image");
            #endif

                Types.Add(type, imageFileName);
            }
        }
开发者ID:DieselPuppet,项目名称:DatingDash,代码行数:18,代码来源:SpawnItemConfig.cs

示例3: GetList

        private static string[] GetList(XmlElement xml, string rootName)
        {
            var listRoot = xml.GetNotEmptyChild(rootName);
            var childElements = listRoot.GetChildElements();
            var result = new string[childElements.Length];

            for (int i = 0; i < childElements.Length; i++)
            {
                string name = childElements[i].Name;

                if (result.Contains(name))
                    throw new LevelXmlException("\"{0}\" contained multiple times in {1} list.", name, rootName);

                result[i] = childElements[i].Name;
            }

            return result;
        }
开发者ID:DieselPuppet,项目名称:DatingDash,代码行数:18,代码来源:TaskConfig.cs


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