SobekCM.Resource_Object.Metadata_File_ReaderWriters.METS_File_ReaderWriter.recursively_add_div_info C# (CSharp) Method

recursively_add_div_info() private method

private recursively_add_div_info ( SobekCM.Resource_Object.Divisions.abstract_TreeNode ThisNode, TextWriter Results, int>.Dictionary PagesToAppearances, int Order ) : void
ThisNode SobekCM.Resource_Object.Divisions.abstract_TreeNode
Results System.IO.TextWriter
PagesToAppearances int>.Dictionary
Order int
return void
        private void recursively_add_div_info(abstract_TreeNode ThisNode, TextWriter Results, Dictionary<abstract_TreeNode, int> PagesToAppearances, int Order)
        {
            // Add the div information for this node first
            if (ThisNode.Page)
            {
                // If the ID of this page is SKIP, then just return and do nothing here
                if (ThisNode.ID == "SKIP")
                    return;

                if (PagesToAppearances.ContainsKey(ThisNode))
                {
                    PagesToAppearances[ThisNode] = PagesToAppearances[ThisNode] + 1;
                    Results.Write("<METS:div ID=\"" + ThisNode.ID + "_repeat" + PagesToAppearances[ThisNode] + "\"");
                }
                else
                {
                    PagesToAppearances[ThisNode] = 1;
                    Results.Write("<METS:div ID=\"" + ThisNode.ID + "\"");
                }
            }
            else
            {
                Results.Write("<METS:div ID=\"" + ThisNode.ID + "\"");
            }

            // Add links to dmd secs and amd secs
            if ( !String.IsNullOrEmpty(ThisNode.DMDID))
            {
                Results.Write(" DMDID=\"" + ThisNode.DMDID + "\"");
            }
            if (!String.IsNullOrEmpty(ThisNode.ADMID))
            {
                Results.Write(" ADMID=\"" + ThisNode.ADMID + "\"");
            }

            // Add the label, if there is one
            if ((ThisNode.Label.Length > 0) && (ThisNode.Label != ThisNode.Type))
                Results.Write(" LABEL=\"" + Convert_String_To_XML_Safe(ThisNode.Label) + "\"");

            // Finish the start div label for this division
            Results.WriteLine(" ORDER=\"" + Order + "\" TYPE=\"" + ThisNode.Type + "\">");

            // If this is a page, add all the files, otherwise call this method recursively
            if (ThisNode.Page)
            {
                // Add each file
                Page_TreeNode thisPage = (Page_TreeNode)ThisNode;
                foreach (SobekCM_File_Info thisFile in thisPage.Files)
                {
                    // Add the file pointer informatino
                    if ( thisFile.ID.Length > 0 )
                        Results.WriteLine("<METS:fptr FILEID=\"" + thisFile.ID + "\" />");
                }
            }
            else
            {
                // Call this method for each subdivision
                int inner_order = 1;
                Division_TreeNode thisDivision = (Division_TreeNode)ThisNode;
                foreach (abstract_TreeNode thisSubDivision in thisDivision.Nodes)
                {
                    recursively_add_div_info(thisSubDivision, Results, PagesToAppearances, inner_order++ );
                }
            }

            // Close out this division
            Results.WriteLine("</METS:div>");
        }