private object ReadXmlNodes(bool elementCanBeType)
{
ArrayList xmlNodeList = new ArrayList();
string elemLocalName = Reader.LocalName;
string elemNs = Reader.NamespaceURI;
string elemName = Reader.Name;
string xsiTypeName = null;
string xsiTypeNs = null;
int skippableNodeCount = 0;
int lineNumber = -1, linePosition = -1;
XmlNode unknownNode = null;
if (Reader.NodeType == XmlNodeType.Attribute)
{
XmlAttribute attr = Document.CreateAttribute(elemName, elemNs);
attr.Value = Reader.Value;
unknownNode = attr;
}
else
unknownNode = Document.CreateElement(elemName, elemNs);
GetCurrentPosition(out lineNumber, out linePosition);
XmlElement unknownElement = unknownNode as XmlElement;
while (Reader.MoveToNextAttribute())
{
if (IsXmlnsAttribute(Reader.Name) || (Reader.Name == "id" && (!_soap12 || Reader.NamespaceURI == Soap12.Encoding)))
skippableNodeCount++;
if ((object)Reader.LocalName == (object)_typeID &&
((object)Reader.NamespaceURI == (object)_instanceNsID ||
(object)Reader.NamespaceURI == (object)_instanceNs2000ID ||
(object)Reader.NamespaceURI == (object)_instanceNs1999ID
)
)
{
string value = Reader.Value;
int colon = value.LastIndexOf(':');
xsiTypeName = (colon >= 0) ? value.Substring(colon + 1) : value;
xsiTypeNs = Reader.LookupNamespace((colon >= 0) ? value.Substring(0, colon) : "");
}
XmlAttribute xmlAttribute = (XmlAttribute)Document.ReadNode(_r);
xmlNodeList.Add(xmlAttribute);
if (unknownElement != null) unknownElement.SetAttributeNode(xmlAttribute);
}
// If the node is referenced (or in case of paramStyle = bare) and if xsi:type is not
// specified then the element name is used as the type name. Reveal this to the user
// by adding an extra attribute node "xsi:type" with value as the element name.
if (elementCanBeType && xsiTypeName == null)
{
xsiTypeName = elemLocalName;
xsiTypeNs = elemNs;
XmlAttribute xsiTypeAttribute = Document.CreateAttribute(_typeID, _instanceNsID);
xsiTypeAttribute.Value = elemName;
xmlNodeList.Add(xsiTypeAttribute);
}
if (xsiTypeName == Soap.UrType &&
((object)xsiTypeNs == (object)_schemaNsID ||
(object)xsiTypeNs == (object)_schemaNs1999ID ||
(object)xsiTypeNs == (object)_schemaNs2000ID
)
)
skippableNodeCount++;
Reader.MoveToElement();
if (Reader.IsEmptyElement)
{
Reader.Skip();
}
else
{
Reader.ReadStartElement();
Reader.MoveToContent();
int whileIterations = 0;
int readerCount = ReaderCount;
while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
{
XmlNode xmlNode = Document.ReadNode(_r);
xmlNodeList.Add(xmlNode);
if (unknownElement != null) unknownElement.AppendChild(xmlNode);
Reader.MoveToContent();
CheckReaderCount(ref whileIterations, ref readerCount);
}
ReadEndElement();
}
if (xmlNodeList.Count <= skippableNodeCount)
return new object();
XmlNode[] childNodes = (XmlNode[])xmlNodeList.ToArray(typeof(XmlNode));
UnknownNode(unknownNode, null, null);
return childNodes;
}