Skip to content

Commit 2c2da31

Browse files
committed
Fixed issues in CurrentGroup.
1 parent fc2bd36 commit 2c2da31

File tree

3 files changed

+46
-14
lines changed

3 files changed

+46
-14
lines changed

KPCLib.xunit/PxDatabaseTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ public class PxLibInfoTests
382382
public void PxLibVersion()
383383
{
384384
Debug.WriteLine($"{PxLibInfo.Version}");
385-
Assert.Equal(PxLibInfo.Version, new System.Version("1.2.0.0"));
385+
Assert.Equal(PxLibInfo.Version, new System.Version("1.2.0.1"));
386386
}
387387

388388
[Fact]

PassXYZLib/PxDatabase.cs

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ namespace PassXYZLib
99
{
1010
public class PxDatabase : PwDatabase
1111
{
12-
/// <summary>
12+
private PwGroup m_pwCurrentGroup = null;
13+
14+
/// <summary>
1315
/// If this is <c>true</c>, a database is currently open.
1416
/// </summary>
1517
public new bool IsOpen
@@ -155,31 +157,57 @@ public class PxDatabase : PwDatabase
155157

156158
public PwGroup CurrentGroup
157159
{
158-
get {
159-
if(this.RootGroup.Uuid == this.LastSelectedGroup)
160-
{ return this.RootGroup; }
160+
get {
161+
if(RootGroup.Uuid == LastSelectedGroup || LastSelectedGroup.Equals(PwUuid.Zero))
162+
{
163+
LastSelectedGroup = RootGroup.Uuid;
164+
m_pwCurrentGroup = RootGroup;
165+
}
166+
return m_pwCurrentGroup;
167+
}
168+
set {
169+
if (value == null) { Debug.Assert(false); throw new ArgumentNullException("value"); }
170+
LastSelectedGroup = value.Uuid;
171+
if (RootGroup.Uuid == LastSelectedGroup || LastSelectedGroup.Equals(PwUuid.Zero))
172+
{
173+
LastSelectedGroup = RootGroup.Uuid;
174+
m_pwCurrentGroup = RootGroup;
175+
}
161176
else
162-
return this.RootGroup.FindGroup(this.LastSelectedGroup, true);
177+
m_pwCurrentGroup = RootGroup.FindGroup(LastSelectedGroup, true);
163178
}
164-
set { this.LastSelectedGroup = value.Uuid; }
165179
}
166180

167181
public string CurrentPath
168182
{
169183
get {
170-
var group = this.CurrentGroup;
171-
string path = this.CurrentGroup.Name + "/";
172-
173-
while (this.RootGroup.Uuid != group.Uuid)
184+
if(CurrentGroup == null)
174185
{
175-
group = group.ParentGroup;
176-
path = group.Name + "/" + path;
186+
return null;
177187
}
188+
else
189+
{
190+
var group = CurrentGroup;
191+
string path = group.Name + "/";
178192

179-
return path;
193+
while (RootGroup.Uuid != group.Uuid)
194+
{
195+
group = group.ParentGroup;
196+
path = group.Name + "/" + path;
197+
}
198+
199+
return path;
200+
}
180201
}
181202
}
182203

204+
/// <summary>
205+
/// Constructs an empty password manager object.
206+
/// </summary>
207+
public PxDatabase() : base()
208+
{
209+
}
210+
183211
private void EnsureRecycleBin(ref PwGroup pgRecycleBin)
184212
{
185213
if (pgRecycleBin == this.RootGroup)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ This is a port of KeePassLib to PCL and .netstandard so that it can be used to b
1111

1212
## Changes:
1313

14+
### Release 1.2.0
15+
- Added PassXYZLib
16+
- Support KPCLibPy
17+
1418
### Release 1.1.9
1519
- Removed dependency of Xamarin.Forms so it can be built with any .Netstandard apps
1620
- Using SkiaSharp to handle Bitmap which is supported by .Netstandard and .Net Core

0 commit comments

Comments
 (0)