1- using System . Diagnostics . CodeAnalysis ;
2- using System . Text . Json ;
1+ using System . Text . Json ;
32using Gommon ;
43using Microsoft . Extensions . Configuration . Json ;
54using Microsoft . Extensions . FileProviders ;
5+ using Ryujinx . Systems . Update . Server . Helpers ;
66using Ryujinx . Systems . Update . Server . Services ;
77
88namespace Ryujinx . Systems . Update . Server ;
@@ -16,69 +16,66 @@ static Config()
1616 if ( ! Directory . Exists ( "config" ) )
1717 Directory . CreateDirectory ( "config" ) ;
1818
19-
2019 DiskProvider = new PhysicalFileProvider ( new FilePath ( Environment . CurrentDirectory ) / "config" ) ;
2120 }
2221
23- public static bool UseVersionPinning ( string [ ] args ,
24- [ MaybeNullWhen ( false ) ] out JsonConfigurationSource jcs )
22+ extension ( WebApplicationBuilder builder )
2523 {
26- jcs = null ;
27-
28- if ( args . Any ( x => x . EqualsIgnoreCase ( "--gen-version-pinning" ) ) )
24+ public void TryUseVersionPinning ( )
2925 {
30- if ( ! File . Exists ( "config/versionPinning.json" ) )
31- File . WriteAllText ( "config/versionPinning.json" ,
32- """
33- {
34- "VersionPinning": {
35- "Stable": {
36- "osx": {
37- "x64": "1.3.4"
26+ if ( CommandLineState . GenerateVersionPinning )
27+ {
28+ if ( ! File . Exists ( "config/versionPinning.json" ) )
29+ File . WriteAllText ( "config/versionPinning.json" ,
30+ """
31+ {
32+ "VersionPinning": {
33+ "Stable": {
34+ "osx": {
35+ "x64": "1.3.4"
36+ }
3837 }
3938 }
4039 }
41- }
42- """
43- ) ;
44- }
45-
46- if ( File . Exists ( "config/versionPinning.json" ) )
47- jcs = new ( )
48- {
49- FileProvider = DiskProvider ,
50- Optional = true ,
51- ReloadOnChange = false ,
52- Path = "versionPinning.json"
53- } ;
40+ """
41+ ) ;
42+ }
5443
55- return jcs != null ;
56- }
44+ if ( File . Exists ( "config/versionPinning.json" ) )
45+ builder . Configuration . Sources . Add ( new JsonConfigurationSource
46+ {
47+ FileProvider = DiskProvider ,
48+ Optional = true ,
49+ ReloadOnChange = false ,
50+ Path = "versionPinning.json"
51+ } ) ;
52+ }
5753
58- public static void TryUseVersionProvider ( this WebApplicationBuilder builder , string [ ] args )
59- {
60- if ( args . Any ( x => x . EqualsIgnoreCase ( "--gen-version-provider" ) ) )
54+ public void TryUseVersionProvider ( )
6155 {
62- if ( ! VersionProvider . Path . ExistsAsFile )
63- VersionProvider . Path . WriteAllText (
64- JsonSerializer . Serialize ( new VersionProvider
65- {
66- Stable = new ( )
67- {
68- Format = "1.{MAJOR}.{BUILD}" ,
69- Major = 3 ,
70- Build = 0
71- } ,
72- Canary = new ( )
56+ if ( CommandLineState . GenerateVersionProvider )
57+ {
58+ if ( ! VersionProvider . Path . ExistsAsFile )
59+ VersionProvider . Path . WriteAllText (
60+ JsonSerializer . Serialize ( new VersionProvider
7361 {
74- Format = "1.{MAJOR}.{BUILD}" ,
75- Major = 3 ,
76- Build = 0
77- }
78- } , JSCtx . ReadableDefault . VersionProvider ) ) ;
79- }
62+ Stable = new ( )
63+ {
64+ Format = "1.{MAJOR}.{BUILD}" ,
65+ Major = 3 ,
66+ Build = 0
67+ } ,
68+ Canary = new ( )
69+ {
70+ Format = "1.{MAJOR}.{BUILD}" ,
71+ Major = 3 ,
72+ Build = 0
73+ }
74+ } , JSCtx . ReadableDefault . VersionProvider ) ) ;
75+ }
8076
81- if ( VersionProvider . Path . ExistsAsFile )
82- builder . Services . AddSingleton < VersionProviderService > ( ) ;
77+ if ( VersionProvider . Path . ExistsAsFile )
78+ builder . Services . AddSingleton < VersionProviderService > ( ) ;
79+ }
8380 }
8481}
0 commit comments