本文整理汇总了C#中System.Xml.XmlElement.GetChildElements方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.GetChildElements方法的具体用法?C# XmlElement.GetChildElements怎么用?C# XmlElement.GetChildElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.GetChildElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public static SpawnItem Load(XmlElement elem, ILog log)
{
string type = elem.Name;
if (!Pack.SpawnItemConfig.Types.Keys.Contains(type))
throw new CommonException("Unknown type: {0}", type);
var result = new SpawnItem(type, elem.GetFloatAttribute(DelayAttribName));
foreach (XmlElement attachElem in elem.GetChildElements())
{
try
{
result.Attachments.Add(SpawnItemAttachment.Load(attachElem));
}
catch (Exception ex)
{
log.Write("Error while loading attachment: {0}. Skipped.", ex.Message);
}
}
return result;
}
示例2: CreateCodeGenerator
private CodeGenerator CreateCodeGenerator(XmlElement domainEl)
{
string[] dlls = domainEl.GetMandatoryAttribute("dlls").Split(',');
CodeGenerator gen = new CodeGenerator();
XmlElement[] entryEls = domainEl.GetChildElements("entry");
_namedEntries.Clear();
foreach (XmlElement entryEl in entryEls)
{
string typeName = entryEl.GetMandatoryAttribute("handle-interface");
string entryName = entryEl.GetMandatoryAttribute("entry-name");
Type handleInterfaceType = null;
for (int i = 0; i < dlls.Length; i++)
{
string fullDllPath = Path.Combine(Directory.GetCurrentDirectory(), dlls[i]);
Assembly asm = Assembly.LoadFile(fullDllPath);
handleInterfaceType = asm.GetType(typeName);
if (handleInterfaceType != null)
{
break;
}
}
if (handleInterfaceType == null)
{
throw new ApplicationException(); // todo2[ak]
}
CodeGeneratorEntry entry = new CodeGeneratorEntry(handleInterfaceType);
gen.AddEntry(entry);
_namedEntries[entryName] = entry;
}
return gen;
}
示例3: Load
public void Load(XmlElement elem, ILog log)
{
if (elem.Name != ElementName)
throw new LevelXmlException("Unexpected element name: \"{0}\". Expected: \"{1}\".", elem.Name, ElementName);
Clear();
foreach (XmlElement itemElem in elem.GetChildElements())
{
try
{
_items.Add(SpawnItem.Load(itemElem, log));
}
catch(Exception ex)
{
log.Write("Error while loading spawn item: {0}. Item is skipped.", ex.Message);
}
}
}