2012-09-28 20:57:30 +00:00
|
|
|
|
using System;
|
2015-04-08 14:50:03 +02:00
|
|
|
|
using System.Collections.Generic;
|
2012-09-28 20:57:30 +00:00
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
|
|
namespace ANX.Framework.Content.Pipeline.Serialization
|
|
|
|
|
{
|
|
|
|
|
public static class XmlReaderExtensions
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Checks if the current document contains the given element.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="xmlReader"></param>
|
|
|
|
|
/// <param name="name">Name of the element</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool CheckForElement(this XmlReader xmlReader, string name)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Element name can not be null!");
|
|
|
|
|
}
|
|
|
|
|
return xmlReader.MoveToContent() == XmlNodeType.Element && xmlReader.Name == name;
|
|
|
|
|
}
|
2015-04-08 14:50:03 +02:00
|
|
|
|
|
|
|
|
|
public static IEnumerable<XmlNode> GetAsEnumerable(this XmlNodeList list)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
yield return list[i];
|
|
|
|
|
}
|
2012-09-28 20:57:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|