本文整理匯總了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;
}