DevTreks.Data/EditHelpers/XmlIO.cs
/// <summary>
/// Append shallow cloned children of the navigator to the element
/// If the child is an annuity node, make a deep clone
/// </summary>
/// <param name="nav"></param>
/// <param name="sDeepClone"></param>
/// <param name="parentElement"></param>
Append shallow cloned children of the navigator to the element
If the child is an annuity node, make a deep clone
Append shallow cloned children of the navigator to the element If the child is an annuity node make a deep clone
public static void AppendChildrenOrAnnuitiesOnly(XPathNavigator nav, 
            bool deepClone, string docToCalcXmlPath, XmlDocument baseDoc,
            ref XmlElement parentNode)
        {
            if (nav.HasChildren == true)
            {
                XPathNodeIterator oChildrenIterator = nav.SelectChildren(XPathNodeType.Element);
                while (oChildrenIterator.MoveNext())
                {
                    XmlElement oChildElement = null;
                    if (oChildrenIterator.Current.LocalName == Helpers.GeneralHelpers.ROOT_PATH)
                    {
                        oChildElement = (XmlElement)((IHasXmlNode)oChildrenIterator.Current).GetNode().CloneNode(true);
                    }
                    else
                    {
                        oChildElement = (XmlElement)((IHasXmlNode)oChildrenIterator.Current).GetNode().CloneNode(deepClone);
                        AddLinkedViewToElement(oChildrenIterator, ref oChildElement);
                    }
                    if (oChildElement != null)
                    {
                        bool bIsAnnuity = IsAnnuityElement(oChildElement);
                        if (bIsAnnuity == false)
                        {
                            parentNode.AppendChild(oChildElement);
                        }
                        else
                        {
                            XmlElement oAnnuityElement = (XmlElement)((IHasXmlNode)oChildrenIterator.Current).GetNode().CloneNode(true);
                            parentNode.AppendChild(oAnnuityElement);
                        }
                    }
                }
            }
        }
public static void AppendChildrenOrAnnuitiesOnly ( XPathNavigator nav , bool deepClone , string docToCalcXmlPath , XmlDocument baseDoc , ref XmlElement parentNode ) { if ( nav . HasChildren == true ) { XPathNodeIterator oChildrenIterator = nav . SelectChildren ( XPathNodeType . Element ) ; while ( oChildrenIterator . MoveNext ( ) ) { XmlElement oChildElement = null ; if ( oChildrenIterator . Current . LocalName == Helpers . GeneralHelpers . ROOT_PATH ) { oChildElement = ( XmlElement ) ( ( IHasXmlNode ) oChildrenIterator . Current ) . GetNode ( ) . CloneNode ( true ) ; } else { oChildElement = ( XmlElement ) ( ( IHasXmlNode ) oChildrenIterator . Current ) . GetNode ( ) . CloneNode ( deepClone ) ; AddLinkedViewToElement ( oChildrenIterator , ref oChildElement ) ; } if ( oChildElement != null ) { bool bIsAnnuity = IsAnnuityElement ( oChildElement ) ; if ( bIsAnnuity == false ) { parentNode . AppendChild ( oChildElement ) ; } else { XmlElement oAnnuityElement = ( XmlElement ) ( ( IHasXmlNode ) oChildrenIterator . Current ) . GetNode ( ) . CloneNode ( true ) ; parentNode . AppendChild ( oAnnuityElement ) ; } } } } }
Append shallow cloned children of the navigator to the element
If the child is an annuity node, make a deep clone
Append shallow cloned children of the navigator to the element If the child is an annuity node make a deep clone
//clone the children //xmldoc els are always deeply cloned (or the document model can get out of shape) //annuity nodes must be deep cloned //always append deep cloned element
nav
XPathNavigator
None
deepClone
bool
docToCalcXmlPath
string
baseDoc
XmlDocument
XmlElement
ref
sDeepClone
None
parentElement
None