コード例 #1
0
        public static PwEntry DuplicateEntryTo(this PwDatabase originalDB, PwEntry originalEntry, PwDatabase copyDB)
        {
            PwGroup copyParent = originalDB.DuplicateGroupTo(originalEntry.ParentGroup, copyDB);
            PwEntry copyEntry  = originalEntry.DuplicateTo(copyParent);

            return(copyEntry);
        }
コード例 #2
0
        /// <summary>
        /// The function finds a specified group (by Uuid) in the copyDb.
        /// The function creates the group if it was not present in the
        /// copyDB yet and ensures the correct path.
        /// </summary>
        /// <param name="sourceDB">The database the group sits in</param>
        /// <param name="group">The parent PwGroup in the original Database.</param>
        /// <param name="destinationDB">The Database where we want to copy the group to.</param>
        /// <returns>The Group in the copy of the database that represents the origGrp in
        /// the original database.</returns>
        public static PwGroup DuplicateGroupTo(this PwDatabase sourceDB, PwGroup group, PwDatabase destinationDB)
        {
            if (group == sourceDB.RootGroup)
            {
                return(destinationDB.RootGroup);
            }
            /* look for the group, if we find it, just return it*/
            PwGroup copyGroup = destinationDB.RootGroup.FindGroup(group.Uuid, true);

            if (copyGroup != null)
            {
                return(copyGroup);
            }
            /* otherwise copy the group to the destination and create the parent if needed */
            PwGroup parentGroup = sourceDB.DuplicateGroupTo(group.ParentGroup, destinationDB);

            copyGroup = group.DuplicateTo(parentGroup);
            return(copyGroup);
        }