File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 3
3
4
4
namespace MojangAPI . Cache
5
5
{
6
- public class JsonFileCacheManager < T > : ICacheManager < T >
6
+ public class JsonFileCacheManager < T > : ICacheManager < T > where T : new ( )
7
7
{
8
8
public string CacheFilePath { get ; private set ; }
9
9
@@ -12,7 +12,7 @@ public JsonFileCacheManager(string filepath)
12
12
this . CacheFilePath = filepath ;
13
13
}
14
14
15
- public virtual T GetDefaultObject ( ) => default ( T ) ;
15
+ public virtual T GetDefaultObject ( ) => new T ( ) ;
16
16
17
17
public T ReadCache ( )
18
18
{
@@ -22,7 +22,7 @@ public T ReadCache()
22
22
try
23
23
{
24
24
string filecontent = File . ReadAllText ( CacheFilePath ) ;
25
- return JsonSerializer . Deserialize < T > ( filecontent ) ;
25
+ return JsonSerializer . Deserialize < T > ( filecontent ) ?? new T ( ) ;
26
26
}
27
27
catch
28
28
{
You can’t perform that action at this time.
0 commit comments