Ejemplo n.º 1
0
        /// <summary>
        /// Propagates possible changes of a rootNode to all of his proxyNodes
        /// </summary>
        /// <param name="root">The rootNode we want to propagate</param>
        /// <returns>True if the function has made changes to the database.</returns>
        private Changes UpdateProxyInformation(PwEntry root)
        {
            Changes changeFlag = Changes.None;
            //get all relevant proxies
            //copy new information from root to proxies
            PwObjectList <PwEntry> allProxies = m_database.GetAllProxyNodes();

            foreach (PwEntry proxy in allProxies)
            {
                //check if the proxy matches to the root and has changes! if not we are done here
                if (proxy.IsProxyOf(root) && !proxy.IsSimilarTo(root, true))
                {
                    PwGroup parent  = proxy.ParentGroup;
                    bool    success = parent.Entries.Remove(proxy);
                    Debug.Assert(success);
                    PwEntry duplicate = root.CloneDeep();
                    duplicate.Uuid = proxy.Uuid;
                    //if the rootNode was a userRoot, the StringFiledUidLink is set automatically in a clone
                    //but if not we have to set it manually
                    if (!root.IsUserRootNode())
                    {
                        duplicate.MakeToProxyOf(root);
                    }
                    duplicate.SetParent(parent);
                    changeFlag |= Changes.EntryCreated;
                }
            }
            return(changeFlag);
        }