Ejemplo n.º 1
0
 /// <summary>
 /// Tertiary constructor used for twin/duplicate XML Definitions within a file.
 /// </summary>
 /// <param name="xmlElement">The differing XML Element for this twin.</param>
 /// <param name="parentTree">he parent XML tree.</param>
 /// <param name="twinTree">The original XML tree.</param>
 private XmlCookedTree(XmlCookedElement xmlElement, XmlCookedTree parentTree, XmlCookedTree twinTree)
 {
     _element = xmlElement;
     Parent = parentTree;
     Definition = twinTree.Definition;
     _twinTree = twinTree;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Secondary constructor used for child node types.
 /// </summary>
 /// <param name="xmlDefinition">The child tree XML Definition.</param>
 /// <param name="xmlElement">The XML Element type (should be of .ElementType = Table or TableCount).</param>
 /// <param name="parentTree">The parent XML tree.</param>
 /// <param name="elementCount">Count of elements in this definition in this XML File.</param>
 public XmlCookedTree(XmlCookedDefinition xmlDefinition, XmlCookedElement xmlElement, XmlCookedTree parentTree, int elementCount)
 {
     Definition = xmlDefinition;
     _element   = xmlElement;
     Parent     = parentTree;
     Count      = elementCount;
     _elements  = new Dictionary <uint, Branch>();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Secondary constructor used for child node types.
 /// </summary>
 /// <param name="xmlDefinition">The child tree XML Definition.</param>
 /// <param name="xmlElement">The XML Element type (should be of .ElementType = Table or TableCount).</param>
 /// <param name="parentTree">The parent XML tree.</param>
 /// <param name="elementCount">Count of elements in this definition in this XML File.</param>
 public XmlCookedTree(XmlCookedDefinition xmlDefinition, XmlCookedElement xmlElement, XmlCookedTree parentTree, int elementCount)
 {
     Definition = xmlDefinition;
     _element = xmlElement;
     Parent = parentTree;
     Count = elementCount;
     _elements = new Dictionary<uint, Branch>();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Replaces last added element with tree. Automatically links the XML Element to tree.
        /// </summary>
        /// <param name="definitionHash">The element name hash of the existing tree.</param>
        public void AddExistingTree(UInt32 definitionHash)
        {
            XmlCookedTree tree = _GetExistingTree(Root, definitionHash);

            Debug.Assert(tree != null, "AddExistingTree: tree not found!");
            tree = tree.TwinRoot;
            Debug.Assert(tree != null, "AddExistingTree: tree not found!");

            XmlCookedElement xmlElement = _elements.Last().Value.Element;
            XmlCookedTree    newTree    = new XmlCookedTree(xmlElement, this, tree);

            AddTree(newTree);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get an already defined definition.
        /// </summary>
        /// <param name="xmlTree"></param>
        /// <param name="elementHash"></param>
        /// <returns></returns>
        private static XmlCookedTree _GetExistingTree(XmlCookedTree xmlTree, UInt32 elementHash)
        {
            foreach (Branch branch in xmlTree._elements.Select(keyValuePair => keyValuePair.Value))
            {
                if (branch.Tree == null)
                {
                    continue;
                }
                if (branch.Tree.DefinitionHash == elementHash)
                {
                    return(branch.Tree);
                }

                XmlCookedTree existingTree = _GetExistingTree(branch.Tree, elementHash);
                if (existingTree != null)
                {
                    return(existingTree);
                }
            }

            return(null);
        }
Ejemplo n.º 6
0
 public Branch(XmlCookedElement element, XmlCookedTree tree = null)
 {
     Element = element;
     Tree    = tree;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Replaces last added element with tree.
 /// </summary>
 /// <param name="xmlCookedFileTree">The tree to the previous element.</param>
 public void AddTree(XmlCookedTree xmlCookedFileTree)
 {
     _elements[_elements.Last().Key] = new Branch(xmlCookedFileTree._element, xmlCookedFileTree);
 }
Ejemplo n.º 8
0
 public Branch(XmlCookedElement element, XmlCookedTree tree=null)
 {
     Element = element;
     Tree = tree;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Get an already defined definition.
        /// </summary>
        /// <param name="xmlTree"></param>
        /// <param name="elementHash"></param>
        /// <returns></returns>
        private static XmlCookedTree _GetExistingTree(XmlCookedTree xmlTree, UInt32 elementHash)
        {
            foreach (Branch branch in xmlTree._elements.Select(keyValuePair => keyValuePair.Value))
            {
                if (branch.Tree == null) continue;
                if (branch.Tree.DefinitionHash == elementHash) return branch.Tree;

                XmlCookedTree existingTree = _GetExistingTree(branch.Tree, elementHash);
                if (existingTree != null) return existingTree;
            }

            return null;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Replaces last added element with tree.
 /// </summary>
 /// <param name="xmlCookedFileTree">The tree to the previous element.</param>
 public void AddTree(XmlCookedTree xmlCookedFileTree)
 {
     _elements[_elements.Last().Key] = new Branch(xmlCookedFileTree._element, xmlCookedFileTree);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Replaces last added element with tree. Automatically links the XML Element to tree.
        /// </summary>
        /// <param name="definitionHash">The element name hash of the existing tree.</param>
        public void AddExistingTree(UInt32 definitionHash)
        {
            XmlCookedTree tree = _GetExistingTree(Root, definitionHash);
            Debug.Assert(tree != null, "AddExistingTree: tree not found!");
            tree = tree.TwinRoot;
            Debug.Assert(tree != null, "AddExistingTree: tree not found!");

            XmlCookedElement xmlElement = _elements.Last().Value.Element;
            XmlCookedTree newTree = new XmlCookedTree(xmlElement, this, tree);
            AddTree(newTree);
        }