/// <summary>
 /// Checks all DOM nodes in the subtree for validity</summary>
 protected override void ValidateSubtree()
 {
     UniqueNamer uniqueNamer = new UniqueNamer(m_suffixSeparator);
     foreach (DomNode node in DomNode.Subtree)
     {
         foreach (DomNode child in node.Children)
         {
             if (child.Type.IdAttribute != null)
             {
                 string id = child.GetId();
                 string uniqueId = uniqueNamer.Name(id);
                 if (id != uniqueId)
                     OnIdCollision(child, uniqueId);
             }
         }
         uniqueNamer.Clear();
     }
 }
Example #2
0
        /// <summary>
        /// Checks all DOM nodes in the subtree for validity</summary>
        protected override void ValidateSubtree()
        {
            UniqueNamer uniqueNamer = new UniqueNamer(m_suffixSeparator);

            foreach (DomNode node in DomNode.Subtree)
            {
                foreach (DomNode child in node.Children)
                {
                    if (child.Type.IdAttribute != null)
                    {
                        string id       = child.GetId();
                        string uniqueId = uniqueNamer.Name(id);
                        if (id != uniqueId)
                        {
                            OnIdCollision(child, uniqueId);
                        }
                    }
                }
                uniqueNamer.Clear();
            }
        }
        void ValidateSubtree(DomNode folder)
        {
            var uniqueNamer = new UniqueNamer();

            foreach (DomNode node in folder.Subtree)
            {
                foreach (DomNode child in node.Children)
                {
                    if (child.Type.IdAttribute != null)
                    {
                        string id       = child.GetId();
                        string uniqueId = uniqueNamer.Name(id);
                        if (id != uniqueId)
                        {
                            throw new InvalidTransactionException("id collision");
                        }
                    }
                }
                uniqueNamer.Clear();
            }
        }
Example #4
0
        /// <summary>
        /// Performs actions for renamed nodes</summary>
        /// <param name="renamed">Renamed nodes and old ids</param>
        protected override void RenameNodes(Dictionary <DomNode, string> renamed)
        {
            HashSet <DomNode> parents = new HashSet <DomNode>();

            foreach (DomNode node in renamed.Keys)
            {
                if (node.Parent != null)
                {
                    parents.Add(node.Parent);
                }
            }

            UniqueNamer uniqueNamer = new UniqueNamer(m_suffixSeparator);

            foreach (DomNode parent in parents)
            {
                // first, initialize namer with the names of the children whose names haven't changed
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        !renamed.ContainsKey(child))
                    {
                        string id = child.GetId();
                        uniqueNamer.Name(id);
                    }
                }

                // now, generate unique ids for the added children
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        renamed.ContainsKey(child))
                    {
                        NameNode(child, uniqueNamer);
                    }
                }

                uniqueNamer.Clear();
            }
        }
Example #5
0
        /// <summary>
        /// Performs actions for added nodes</summary>
        /// <param name="added">Added nodes</param>
        /// <param name="renamed">Renamed nodes and old ids</param>
        protected override void AddNodes(HashSet <DomNode> added, Dictionary <DomNode, string> renamed)
        {
            HashSet <DomNode> parents = new HashSet <DomNode>();

            foreach (DomNode node in added)
            {
                renamed.Remove(node);
                parents.Add(node.Parent);
            }

            UniqueNamer uniqueNamer = new UniqueNamer(m_suffixSeparator);

            foreach (DomNode parent in parents)
            {
                // first, initialize namer with the names of the pre-existing children
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        !added.Contains(child))
                    {
                        string id = child.GetId();
                        uniqueNamer.Name(id);
                    }
                }

                // now, generate unique ids for the added children
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        added.Contains(child))
                    {
                        NameNode(child, uniqueNamer);
                    }
                }

                uniqueNamer.Clear();
            }
        }
        /// <summary>
        /// Performs actions for renamed nodes</summary>
        /// <param name="renamed">Renamed nodes and old ids</param>
        protected override void RenameNodes(Dictionary<DomNode, string> renamed)
        {
            HashSet<DomNode> parents = new HashSet<DomNode>();
            foreach (DomNode node in renamed.Keys)
                parents.Add(node.Parent);

            UniqueNamer uniqueNamer = new UniqueNamer(m_suffixSeparator);
            foreach (DomNode parent in parents)
            {
                // first, initialize namer with the names of the children whose names haven't changed
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        !renamed.ContainsKey(child))
                    {
                        string id = child.GetId();
                        uniqueNamer.Name(id);
                    }
                }

                // now, generate unique ids for the added children
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        renamed.ContainsKey(child))
                    {
                        NameNode(child, uniqueNamer);
                    }
                }

                uniqueNamer.Clear();
            }
        }
        /// <summary>
        /// Performs actions for added nodes</summary>
        /// <param name="added">Added nodes</param>
        /// <param name="renamed">Renamed nodes and old ids</param>
        protected override void AddNodes(HashSet<DomNode> added, Dictionary<DomNode, string> renamed)
        {
            HashSet<DomNode> parents = new HashSet<DomNode>();
            foreach (DomNode node in added)
            {
                renamed.Remove(node);
                parents.Add(node.Parent);
            }

            UniqueNamer uniqueNamer = new UniqueNamer(m_suffixSeparator);
            foreach (DomNode parent in parents)
            {
                // first, initialize namer with the names of the pre-existing children
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        !added.Contains(child))
                    {
                        string id = child.GetId();
                        uniqueNamer.Name(id);
                    }
                }

                // now, generate unique ids for the added children
                foreach (DomNode child in parent.Children)
                {
                    if (child.Type.IdAttribute != null &&
                        added.Contains(child))
                    {
                        NameNode(child, uniqueNamer);
                    }
                }

                uniqueNamer.Clear();
            }
        }