private XmlNode CloneNode(DataPointer dp)
{
switch (dp.NodeType)
{
//for the nodes without value and have no children
case XmlNodeType.DocumentFragment:
return CreateDocumentFragment();
case XmlNodeType.DocumentType:
return CreateDocumentType(dp.Name, dp.PublicId, dp.SystemId, dp.InternalSubset);
case XmlNodeType.XmlDeclaration:
return CreateXmlDeclaration(dp.Version, dp.Encoding, dp.Standalone);
//for the nodes with value but no children
case XmlNodeType.Text:
return CreateTextNode(dp.Value);
case XmlNodeType.CDATA:
return CreateCDataSection(dp.Value);
case XmlNodeType.ProcessingInstruction:
return CreateProcessingInstruction(dp.Name, dp.Value);
case XmlNodeType.Comment:
return CreateComment(dp.Value);
case XmlNodeType.Whitespace:
return CreateWhitespace(dp.Value);
case XmlNodeType.SignificantWhitespace:
return CreateSignificantWhitespace(dp.Value);
//for the nodes that don't have values, but might have children -- only clone the node and leave the children untouched
case XmlNodeType.Element:
return CreateElement(dp.Prefix, dp.LocalName, dp.NamespaceURI);
case XmlNodeType.Attribute:
return CreateAttribute(dp.Prefix, dp.LocalName, dp.NamespaceURI);
case XmlNodeType.EntityReference:
return CreateEntityReference(dp.Name);
}
throw new InvalidOperationException(SR.Format(SR.DataDom_CloneNode, dp.NodeType.ToString()));
}