Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 9c95f34

Browse files
Ensure FirstRunAtValue is populated
Ensure FirstRun is resolved before FirstRunAt is called
1 parent d02baef commit 9c95f34

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,7 @@ public bool FirstRun
1919
{
2020
get
2121
{
22-
if (!firstRunValue.HasValue)
23-
{
24-
firstRunValue = firstRun;
25-
}
26-
27-
if (firstRun)
28-
{
29-
firstRun = false;
30-
FirstRunAt = DateTimeOffset.Now;
31-
Save(true);
32-
}
33-
22+
EnsureFirstRun();
3423
return firstRunValue.Value;
3524
}
3625
}
@@ -39,17 +28,34 @@ public DateTimeOffset FirstRunAt
3928
{
4029
get
4130
{
31+
EnsureFirstRun();
32+
4233
if (!firstRunAtValue.HasValue)
4334
{
44-
firstRunAtValue = DateTimeOffset.Parse(firstRunAtString);
35+
firstRunAtValue = DateTimeOffset.ParseExact(firstRunAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture);
4536
}
4637

4738
return firstRunAtValue.Value;
4839
}
4940
private set
5041
{
51-
firstRunAtString = value.ToString();
52-
firstRunAtValue = null;
42+
firstRunAtString = value.ToString(Constants.Iso8601Format);
43+
firstRunAtValue = value;
44+
}
45+
}
46+
47+
private void EnsureFirstRun()
48+
{
49+
if (!firstRunValue.HasValue)
50+
{
51+
firstRunValue = firstRun;
52+
}
53+
54+
if (firstRun)
55+
{
56+
firstRun = false;
57+
FirstRunAt = DateTimeOffset.Now;
58+
Save(true);
5359
}
5460
}
5561
}

0 commit comments

Comments
 (0)