1+ using ICSharpCode . SharpZipLib . Zip ;
12using System . Globalization ;
23using System . Xml . Linq ;
3- using ICSharpCode . SharpZipLib . Zip ;
44
55namespace RTK
66{
@@ -309,14 +309,14 @@ internal static (bool, string) TranscriptionProcessing(string CurrentFile, bool
309309 internal static ( bool , string ) CheckConfig ( string CurrentFile )
310310 {
311311 string error = string . Empty ;
312+ XDocument xdoc = new ( ) ;
312313 if ( ! File . Exists ( "config.xml" ) )
313314 {
314- XDocument xdoc = new XDocument ( ) ;
315315 XElement configuration = new XElement ( "configuration" ) ;
316316 XElement xmlsha = new XElement ( "sha" , "0" ) ;
317317 XElement xmllanguage = new XElement ( "language" , "Russian(GitHub)" ) ;
318318 XElement xmldirectory = new XElement ( "directory" , CurrentFile ) ;
319- XElement xmlrepo = new XElement ( "repo" , "RimWorld-ru" ) ;
319+ XElement xmlrepo = new XElement ( "repo" , "RimWorld-ru" ) ;
320320 configuration . Add ( xmlsha ) ;
321321 configuration . Add ( xmllanguage ) ;
322322 configuration . Add ( xmldirectory ) ;
@@ -328,46 +328,22 @@ internal static (bool, string) CheckConfig(string CurrentFile)
328328 }
329329 else
330330 {
331- XDocument xdoc ;
332- try
333- {
334- xdoc = XDocument . Load ( "config.xml" ) ;
335- }
336- catch
337- {
338- error = "Ôàéë íàñòðîåê ïîâðåæä¸í." ;
339- return ( false , error ) ;
340- }
341- XElement ? configuration = xdoc . Element ( "configuration" ) ;
342- if ( configuration . IsEmpty )
343- {
344- error = "Ôàéë íàñòðîåê ïîâðåæä¸í." ;
345- return ( false , error ) ;
346- }
347- string ? sha = configuration . Element ( "sha" ) ? . Value ;
348- if ( sha is null )
349- {
350- error = "Ôàéë íàñòðîåê ïîâðåæä¸í." ;
351- return ( false , error ) ;
352- }
353- string ? language = configuration . Element ( "language" ) ? . Value ;
354- if ( language is null )
355- {
356- error = "Ôàéë íàñòðîåê ïîâðåæä¸í." ;
357- return ( false , error ) ;
358- }
359- string ? directory = configuration . Element ( "directory" ) ? . Value ;
360- if ( directory is null )
361- {
362- error = "Ôàéë íàñòðîåê ïîâðåæä¸í." ;
363- return ( false , error ) ;
364- }
365- string ? repo = configuration . Element ( "repo" ) ? . Value ;
366- if ( repo is null )
367- {
368- error = "Ôàéë íàñòðîåê ïîâðåæä¸í." ;
369- return ( false , error ) ;
370- }
331+ string ? temp ;
332+ error = "Ôàéë íàñòðîåê ïîâðåæä¸í." ;
333+ try { xdoc = XDocument . Load ( "config.xml" ) ; }
334+ catch { return ( false , error ) ; }
335+ try { temp = xdoc . Element ( "configuration" ) ? . Element ( "sha" ) ? . Value ; }
336+ catch { return ( false , error ) ; }
337+ if ( temp is null ) return ( false , error ) ;
338+ try { temp = xdoc . Element ( "configuration" ) ? . Element ( "language" ) ? . Value ; }
339+ catch { return ( false , error ) ; }
340+ if ( temp is null ) return ( false , error ) ;
341+ try { temp = xdoc . Element ( "configuration" ) ? . Element ( "directory" ) ? . Value ; }
342+ catch { return ( false , error ) ; }
343+ if ( temp is null ) return ( false , error ) ;
344+ try { temp = xdoc . Element ( "configuration" ) ? . Element ( "repo" ) ? . Value ; }
345+ catch { return ( false , error ) ; }
346+ if ( temp is null ) return ( false , error ) ;
371347 }
372348 return ( true , error ) ;
373349 }
0 commit comments