Beispiel #1
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);
        }
 /// <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="originalDB">Ausgangsdatenbank</param>
 /// <param name="originalGroup">The parent PwGroup in the original Database.</param>
 /// <param name="copyDB">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 originalDB, PwGroup originalGroup, PwDatabase copyDB)
 {
     if (originalGroup == originalDB.RootGroup)
     {
         return copyDB.RootGroup;
     }
     PwGroup copyGroup = copyDB.RootGroup.FindGroup(originalGroup.Uuid, true);
     if (copyGroup != null)
     {
         return copyGroup;
     }
     PwGroup copyParent = originalDB.DuplicateGroupTo(originalGroup.ParentGroup, copyDB);
     copyGroup = originalGroup.DuplicateTo(copyParent);
     return copyGroup;
 }