コード例 #1
0
        static void DictionaryItem_Deleting(Dictionary.DictionaryItem sender, EventArgs e)
        {
            lock (_deleteLock)
            {
                if (sender.hasChildren)
                {
                    // we get the delets in a backwards order, so we add all the children of this
                    // node to the list we are not going to delete when we get asked to.
                    // 
                    foreach(Dictionary.DictionaryItem child in sender.Children)
                    {
                        _dChildren.Add(child.id) ; 
                    }
                }

                if (_dChildren.Contains(sender.id))
                {
                    // this is a child of a parent we have already deleted.
                    _dChildren.Remove(sender.id);
                    LogHelper.Debug<uSync>("No Deleteing Dictionary item {0} because we deleted it's parent", ()=> sender.key); 
                }
                else
                {
                    //actually delete 


                    LogHelper.Debug<uSync>("Deleting Dictionary Item {0}", ()=> sender.key);

                    // when you delete a tree, the top gets called before the children. 
                    //             
                    if (!sender.IsTopMostItem())
                    {
                        // if it's not top most, we save it's parent (that will delete)

                        SaveToDisk(GetTop(sender));
                    }
                    else
                    {
                        // it's top we need to delete
                        helpers.XmlDoc.ArchiveFile("Dictionary", sender.key);

                    }
                }
            }
            
            
            

        }
コード例 #2
0
        private static Dictionary.DictionaryItem GetTop(Dictionary.DictionaryItem item)
        {
            if (!item.IsTopMostItem())
            {
                LogHelper.Debug<uSync>("is Top Most [{0}]", ()=> item.IsTopMostItem());
                try
                {
                    if (item.Parent != null)
                    {
                        LogHelper.Debug<uSync>("parent [{0}]", () => item.Parent.key);
                        return GetTop(item.Parent);
                    }
                }
                catch (ArgumentException aex)
                {
                    LogHelper.Info<uSync>("Argument Exception - basically Parent is Null");
                }
            }

            return item; 

        }