@@ -30,8 +30,10 @@ public class RouteSettings
3030 {
3131 public class Route
3232 {
33- public string DateInstalled { get ; set ; }
34- public string Url { get ; set ; }
33+ public string DateInstalled ;
34+
35+ public string DirectoryInstalledIn ;
36+ public string Url ;
3537
3638 public long DownloadSize ;
3739 public long InstallSize ;
@@ -40,14 +42,27 @@ public class Route
4042
4143 public string Description ;
4244
43- public Route ( string dateInstalled , string url , long downloadSize , long installSize , string image , string description )
45+ public string AuthorName ;
46+ public string AuthorUrl ;
47+
48+ public string Screenshot ;
49+
50+ public Route ( string dateInstalled , string directoryInstalledIn , string url ,
51+ long downloadSize , long installSize ,
52+ string image , string description ,
53+ string author , string authorUrl ,
54+ string screenshot )
4455 {
4556 DateInstalled = dateInstalled ;
57+ DirectoryInstalledIn = directoryInstalledIn ;
4658 Url = url ;
4759 DownloadSize = downloadSize ;
4860 InstallSize = installSize ;
4961 Image = image ;
5062 Description = description ;
63+ AuthorName = author ;
64+ AuthorUrl = authorUrl ;
65+ Screenshot = screenshot ;
5166 }
5267 }
5368
@@ -86,14 +101,16 @@ public void LoadContentAndInstalled()
86101 }
87102 }
88103
104+ // only for debug purposes
89105 string definedContentJsonName = @"d:\content\routes.json" ;
90106
91107 string definedContentJsonDirectoryName = Path . GetTempFileName ( ) ;
92108 File . Delete ( definedContentJsonDirectoryName ) ;
93109
94110 string githubUrl = "https://github.com/openrails/content.git" ; ;
95111
96- if ( Environment . GetEnvironmentVariable ( "TstLoadContentAndInstalled" ) == null )
112+ if ( string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "TstLoadContentAndInstalled" ) ) ||
113+ ( Environment . GetEnvironmentVariable ( "TstLoadContentAndInstalled" ) != "1" ) )
97114 {
98115 try
99116 {
@@ -124,12 +141,22 @@ public void LoadContentAndInstalled()
124141 long installSize = convertResultToLong ( result , "installSize" ) ;
125142 string image = convertResultToString ( result , "image" ) ;
126143 string description = convertResultToString ( result , "description" ) ;
144+ JToken author = result [ "author" ] ;
145+ string authorName = convertResultToString ( author , "name" ) ;
146+ string authorUrl = convertResultToString ( author , "url" ) ;
147+ string screenshot = convertResultToString ( result , "screenshot" ) ;
127148
128149 if ( url . EndsWith ( ".git" ) || url . EndsWith ( ".zip" ) )
129150 {
130151 if ( ! Routes . ContainsKey ( routeName ) )
131152 {
132- Routes . Add ( routeName , new RouteSettings . Route ( "" , url , downloadSize , installSize , image , description ) ) ;
153+ Routes . Add ( routeName , new RouteSettings . Route (
154+ "" , "" , url , downloadSize , installSize , image , description , authorName , authorUrl , screenshot ) ) ;
155+ }
156+ else
157+ {
158+ update ( Routes [ routeName ] ,
159+ url , downloadSize , installSize , image , description , authorName , authorUrl , screenshot ) ;
133160 }
134161 }
135162 }
@@ -145,6 +172,23 @@ public void LoadContentAndInstalled()
145172 return ;
146173 }
147174
175+ private void update ( Route route ,
176+ string url ,
177+ long downloadSize , long installSize ,
178+ string img , string description ,
179+ string authorName , string authorUrl ,
180+ string screenshot )
181+ {
182+ route . Url = url ;
183+ route . DownloadSize = downloadSize ;
184+ route . InstallSize = installSize ;
185+ route . Image = img ;
186+ route . Description = description ;
187+ route . AuthorName = authorName ;
188+ route . AuthorUrl = authorUrl ;
189+ route . Screenshot = screenshot ;
190+ }
191+
148192 private long convertResultToLong ( JToken result , string fieldName )
149193 {
150194 if ( result [ fieldName ] != null )
@@ -183,8 +227,10 @@ private void directoryRemoveReadOnlyFlags(string directoryName)
183227 {
184228 foreach ( string filename in Directory . GetFiles ( directoryName ) )
185229 {
186- FileInfo file = new FileInfo ( filename ) ;
187- file . IsReadOnly = false ;
230+ _ = new FileInfo ( filename )
231+ {
232+ IsReadOnly = false
233+ } ;
188234 }
189235 foreach ( string subDirectoryName in Directory . GetDirectories ( directoryName ) )
190236 {
0 commit comments