コード例 #1
0
        /// <summary>
        /// The <c>RemoveBrokenProxies</c> function finds all proxies which have no valid
        /// UserRootNode or normal PwEntry as target and deletes them.
        /// </summary>
        /// <returns><c>ChangeFlags</c>It will set the ChangeFlags.CommonChange-flag if this function has made changes in the datastructure.
        /// Should be used to triger an UIupdate if you want to show the changes.</returns>
        private Changes RemoveBrokenProxies()
        {
            HashSet <string> uids = new HashSet <string>();

            //create list for the uuids because this way we can easily find a stringValue
            foreach (PwEntry target in m_database.GetAllProxyTargets())
            {
                uids.Add(target.Uuid.ToHexString());
            }

            Changes changeFlag = Changes.None;

            foreach (PwEntry proxy in m_database.GetAllProxyNodes())
            {
                if (!uids.Contains(proxy.Strings.ReadSafe(KeeShare.UuidLinkField)))
                {
                    //remove all brokenProxies because without their rootNode_X they are useless ..
                    proxy.DeleteFrom(proxy.ParentGroup, m_database);
                    changeFlag |= Changes.EntryDeleted;
                }
            }

            return(changeFlag);
        }