Skip to content

Commit a49c1f3

Browse files
committed
caching refactored via lazy class
1 parent b7d73f4 commit a49c1f3

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Core/AppVersionHelper.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,8 @@ public class AppVersionHelper
1919
/// Gets release (last build) date of the application.
2020
/// It's shown in the web page.
2121
/// </summary>
22-
public static DateTime ReleaseDate
23-
{
24-
get
25-
{
26-
if (_cachedReleaseDate.HasValue)
27-
return _cachedReleaseDate.Value;
22+
public static DateTime ReleaseDate => LzyReleaseDate.Value;
2823

29-
_cachedReleaseDate = new FileInfo(typeof(AppVersionHelper).GetAssembly().Location).LastWriteTime;
30-
31-
return _cachedReleaseDate.Value;
32-
}
33-
}
34-
private static DateTime? _cachedReleaseDate;
24+
private static readonly Lazy<DateTime> LzyReleaseDate = new Lazy<DateTime>(() => new FileInfo(typeof(AppVersionHelper).GetAssembly().Location).LastWriteTime);
3525
}
3626
}

0 commit comments

Comments
 (0)