public static XmlNode[] ReadNodes(XmlReader xmlReader)
{
if (xmlReader == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
XmlDocument doc = new XmlDocument();
List<XmlNode> nodeList = new List<XmlNode>();
if (xmlReader.MoveToFirstAttribute())
{
do
{
if (IsValidAttribute(xmlReader))
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
} while (xmlReader.MoveToNextAttribute());
}
xmlReader.MoveToElement();
if (!xmlReader.IsEmptyElement)
{
int startDepth = xmlReader.Depth;
xmlReader.Read();
while (xmlReader.Depth > startDepth && xmlReader.NodeType != XmlNodeType.EndElement)
{
XmlNode node = doc.ReadNode(xmlReader);
if (node == null)
throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlObjectSerializer.CreateSerializationException(SR.GetString(SR.UnexpectedEndOfFile)));
nodeList.Add(node);
}
}
return nodeList.ToArray();
}