本文整理汇总了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);
}
}
}
示例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);
}
}
示例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;
}