File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
LoopMusicPlayer/DataClass Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 33using System . IO ;
44using System . Reflection . PortableExecutable ;
55using System . Text . Json ;
6+ using System . Text . Json . Serialization ;
67
78namespace LoopMusicPlayer . DataClass ;
89
@@ -16,7 +17,7 @@ public static Settings Load()
1617 {
1718 try
1819 {
19- Settings ? settings = JsonSerializer . Deserialize < Settings > ( File . ReadAllBytes ( _settingPath ) ) ;
20+ Settings ? settings = JsonSerializer . Deserialize < Settings > ( File . ReadAllBytes ( _settingPath ) , SettingsSourceGenerationContext . Default . Settings ) ;
2021 if ( settings is not null )
2122 return settings ;
2223 }
@@ -32,7 +33,7 @@ public void Save()
3233 {
3334 try
3435 {
35- File . WriteAllBytes ( _settingPath , JsonSerializer . SerializeToUtf8Bytes ( this ) ) ;
36+ File . WriteAllBytes ( _settingPath , JsonSerializer . SerializeToUtf8Bytes ( this , SettingsSourceGenerationContext . Default . Settings ) ) ;
3637 }
3738 catch ( Exception e )
3839 {
@@ -115,3 +116,9 @@ public enum ETimeFormat
115116 }
116117 }
117118}
119+
120+ [ JsonSourceGenerationOptions ( WriteIndented = false ) ]
121+ [ JsonSerializable ( typeof ( Settings ) ) ]
122+ internal partial class SettingsSourceGenerationContext : JsonSerializerContext
123+ {
124+ }
You can’t perform that action at this time.
0 commit comments