/// <summary> /// The function compares two PwEntries in every scope except the Uuid /// </summary> /// <param name="entry1">the first entry</param> /// <param name="entry2">the second entry</param> /// <param name="bIgnoreKeeShareFields">Should the KeeShare-specific fields be ignored?</param> /// <returns>True if both entries are equal in all field, accordingly to the parametersettings</returns> public static bool IsSimilarTo(this PwEntry entry1, PwEntry entry2, bool bIgnoreKeeShareFields) { //if both are null they are equal if (entry1 == null && entry2 == null) { return true; } //if only one of them is null we could not clone it => they are not equal if (entry1 == null || entry2 == null) { return false; } PwEntry copy1 = entry1.CloneDeep(); PwEntry copy2 = entry2.CloneDeep(); if (bIgnoreKeeShareFields) { copy1.Strings.Remove(KeeShare.UuidLinkField); copy2.Strings.Remove(KeeShare.UuidLinkField); } //we have to make the Uuids and creation times equal, because PwEntry.EqualsEntry compares these too //and returns false if they are not equal!! copy1.SetUuid(copy2.Uuid, false); copy1.CreationTime = copy2.CreationTime; PwCompareOptions opts = PwCompareOptions.IgnoreHistory | PwCompareOptions.IgnoreLastAccess | PwCompareOptions.IgnoreLastBackup | PwCompareOptions.IgnoreLastMod | PwCompareOptions.IgnoreParentGroup | PwCompareOptions.IgnoreTimes; return copy1.EqualsEntry(copy2, opts, MemProtCmpMode.Full); }
public static PwEntry DuplicateTo(this PwEntry entry, PwGroup parent) { PwEntry copy = entry.CloneDeep(); //we dont want to share our history copy.History.Clear(); //HACK: CloneDeep introduces the copy into the parent node, therefore SetParent triggers a change of the parent // which shouldn't be - the extended ProtectionSection in KeeShare should prevent interference, but a // a clean way to clone a node without cloning children and without hooking it into a tree would be nice copy.SetParent(parent); return copy; }