22using System . Collections . Generic ;
33using System . IO ;
44using System . Linq ;
5+ using System . Text ;
56using Sander . QuickList . Application . Enums ;
67
78namespace Sander . QuickList . Application
@@ -57,6 +58,9 @@ internal sealed class Configuration
5758 /// </summary>
5859 internal bool ForceShellMedia { get ; set ; }
5960
61+ /// <summary>
62+ /// Status/progress to display on form
63+ /// </summary>
6064 internal Status Status { get ; set ; }
6165
6266 /// <summary>
@@ -74,6 +78,7 @@ internal sealed class Configuration
7478 /// </summary>
7579 internal List < string > ExcludedFilenames { get ; set ; }
7680
81+
7782 internal static Configuration Parse ( string iniFile )
7883 {
7984 var configuration = new Configuration
@@ -90,7 +95,6 @@ internal static Configuration Parse(string iniFile)
9095 ForceShellMedia = IniReader . ReadValue ( "QuickList" , "ForceShellMedia" , iniFile , "0" ) == "1"
9196 } ;
9297
93-
9498 var excludedExtensions = IniReader . ReadValue ( "ListMagic" , "Exclude" , iniFile ) ;
9599
96100 if ( ! string . IsNullOrWhiteSpace ( excludedExtensions ) )
@@ -102,7 +106,7 @@ internal static Configuration Parse(string iniFile)
102106
103107 int . TryParse ( IniReader . ReadValue ( "QuickList" , "FileReaderParallelism" , iniFile , "1" ) , out var fileReaderParallelism ) ;
104108 if ( fileReaderParallelism <= 0 )
105- fileReaderParallelism = 1 ;
109+ fileReaderParallelism = 1 ;
106110
107111 configuration . FileReaderParallelism = fileReaderParallelism ;
108112
@@ -111,9 +115,9 @@ internal static Configuration Parse(string iniFile)
111115 if ( ! string . IsNullOrWhiteSpace ( excludedFilenames ) )
112116 {
113117 configuration . ExcludedFilenames = excludedFilenames
114- . Split ( new [ ] { ':' } )
115- . Select ( x => x . Trim ( ) )
116- . ToList ( ) ;
118+ . Split ( new [ ] { ':' } , StringSplitOptions . RemoveEmptyEntries )
119+ . Select ( x => x . Trim ( ) )
120+ . ToList ( ) ;
117121 }
118122
119123 var dirsFile = IniReader . ReadValue ( "ListMagic" , "DirsFile" , iniFile ) ;
@@ -122,10 +126,10 @@ internal static Configuration Parse(string iniFile)
122126 throw new FileNotFoundException ( $ "Folders file \" { dirsFile } \" does not exist!") ;
123127
124128 var folders = File . ReadAllLines ( dirsFile )
125- . Select ( x => x . Trim ( ) )
126- . Where ( x => ! string . IsNullOrWhiteSpace ( x ) )
127- . Distinct ( )
128- . ToList ( ) ;
129+ . Select ( x => x . Trim ( ) )
130+ . Where ( x => ! string . IsNullOrWhiteSpace ( x ) )
131+ . Distinct ( )
132+ . ToList ( ) ;
129133
130134 configuration . InputFolders = folders ;
131135 configuration . Validate ( ) ;
@@ -155,8 +159,30 @@ internal void Update()
155159 IniReader . WriteValue ( "QuickList" , "ForceShellMedia" , ForceShellMedia ? "1" : "0" , IniFile ) ;
156160 IniReader . WriteValue ( "QuickList" , "FileReaderParallelism" , FileReaderParallelism . ToString ( ) , IniFile ) ;
157161
158- if ( ExcludedFilenames ? . Count > 0 )
159- IniReader . WriteValue ( "QuickList" , "ExcludedFilenames" , string . Join ( ":" , ExcludedFilenames ) , IniFile ) ;
162+ if ( ExcludedFilenames ? . Count > 0 )
163+ IniReader . WriteValue ( "QuickList" , "ExcludedFilenames" , string . Join ( ":" , ExcludedFilenames ) , IniFile ) ;
164+ }
165+
166+
167+ /// <inheritdoc />
168+ public override string ToString ( )
169+ {
170+ var sb = new StringBuilder ( "\r \n === Configuration ===\r \n " ) ;
171+ sb . AppendLine ( $ "IniFile: { IniFile } ") ;
172+ sb . AppendLine ( $ "ListName: { ListName } ") ;
173+ sb . AppendLine ( $ "Trigger: { Trigger } ") ;
174+ sb . AppendLine ( $ "InputFolders: { string . Join ( ";" , InputFolders ) } ") ;
175+ sb . AppendLine ( $ "OutputFolder: { OutputFolder } ") ;
176+ sb . AppendLine ( $ "HeaderFile: { HeaderFile } ") ;
177+ sb . AppendLine ( $ "FileInfoLevel: { FileInfo } ") ;
178+ sb . AppendLine ( $ "FolderHandling: { FolderHandling } ") ;
179+ sb . AppendLine ( $ "ShowUi: { ShowUi } ") ;
180+ sb . AppendLine ( $ "FileReaderParallelism: { FileReaderParallelism } ") ;
181+ sb . AppendLine ( $ "ExcludedExtensions: { string . Join ( ";" , ExcludedExtensions ) } ") ;
182+ sb . AppendLine ( $ "ExcludedFilenames: { string . Join ( ";" , ExcludedFilenames ) } ") ;
183+ sb . AppendLine ( $ "MediaCacheFile: { MediaCacheFile } ") ;
184+ sb . AppendLine ( $ "ForceShellMedia: { ForceShellMedia } ") ;
185+ return sb . ToString ( ) ;
160186 }
161187 }
162188}
0 commit comments