Skip to content

Commit ca1fc41

Browse files
committed
Added FindEntryById()
1 parent f9f4830 commit ca1fc41

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

PassXYZLib.nuspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
<projectUrl>https://github.com/passxyz/KPCLib</projectUrl>
1111
<description>This is an extension of KPCLib.</description>
1212
<releaseNotes>
13-
- Removed dependencies
14-
- Added Delete function in Class User
13+
- Added FindEntryById()
1514
</releaseNotes>
1615
<copyright>Roger Ye</copyright>
1716
<repository url="https://github.com/passxyz/KPCLib" />

PassXYZLib/PxDatabase.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using SkiaSharp;
88

99
using KeePassLib;
10-
using KeePassLib.Interfaces;
10+
using KeePassLib.Delegates;
1111
using KeePassLib.Keys;
1212
using KeePassLib.Security;
1313
using KeePassLib.Serialization;
@@ -540,6 +540,33 @@ PwGroup FindSubgroup(PwGroup group, string name)
540540
}
541541

542542

543+
/// <summary>
544+
/// Find an entry by Uuid
545+
/// </summary>
546+
/// <param name="uuid">The entry uuid</param>
547+
/// <returns>Entry found or return <c>null</c> if the entry cannot be found</returns>
548+
public PwEntry FindEntryById(string id)
549+
{
550+
PwEntry targetEntry = null;
551+
552+
EntryHandler eh = delegate (PwEntry pe)
553+
{
554+
PwUuid pu = pe.Uuid;
555+
string hexStr = pu.ToHexString();
556+
if (hexStr.Equals(id))
557+
{
558+
targetEntry = pe;
559+
return false;
560+
}
561+
562+
return true;
563+
};
564+
565+
RootGroup.TraverseTree(TraversalMethod.PreOrder, null, eh);
566+
567+
return targetEntry;
568+
}
569+
543570
/// <summary>
544571
/// Delete a group.
545572
/// </summary>

0 commit comments

Comments
 (0)