minor refactor
This commit is contained in:
parent
5366b11f55
commit
1cfb8be85b
7 changed files with 139 additions and 137 deletions
|
@ -1,6 +1,6 @@
|
|||
namespace Configuration
|
||||
{
|
||||
public sealed class DemoApplicationConfiguration
|
||||
public sealed class ApplicationConfigurationService
|
||||
{
|
||||
private FileInfo[] jsonFiles;
|
||||
public FileInfo[] JsonFilesInfo
|
||||
|
@ -22,7 +22,7 @@ namespace Configuration
|
|||
}
|
||||
}
|
||||
|
||||
public static DemoApplicationConfiguration InitializeFrom(string[] args)
|
||||
public static ApplicationConfigurationService InitializeFrom(string[] args)
|
||||
{
|
||||
if (args.Length < 3)
|
||||
throw new DemoApplicationConfigurationException("Must have atleast: 1 flag, 1 path, 1 output filename");
|
||||
|
@ -41,14 +41,14 @@ namespace Configuration
|
|||
// Assert only a single 'd' was passed
|
||||
if ( givenFlags.Length == 1 && givenFlags[0].Equals("-d") ) {
|
||||
string[] filesInDirectory = Directory.GetFiles(givenFilePaths[0]);
|
||||
return new DemoApplicationConfiguration {
|
||||
return new ApplicationConfigurationService {
|
||||
OutputFile = outputFileName,
|
||||
JsonFilesInfo = filesInDirectory.Select(name => new FileInfo(name)).ToArray(),
|
||||
};
|
||||
}
|
||||
// Assert only '-f' were passed
|
||||
else if (givenFlags.All((string flag) => flag.Equals("-f"))) {
|
||||
return new DemoApplicationConfiguration {
|
||||
return new ApplicationConfigurationService {
|
||||
OutputFile = outputFileName,
|
||||
JsonFilesInfo = givenFilePaths.Select(name => new FileInfo(name)).ToArray(),
|
||||
};
|
|
@ -1,12 +1,12 @@
|
|||
using System.Globalization;
|
||||
using CsvHelper;
|
||||
|
||||
class CsvFileWriter
|
||||
class CsvFileWriterService
|
||||
{
|
||||
private TextWriter textWriter;
|
||||
private CsvWriter csvWriter;
|
||||
|
||||
public CsvFileWriter(FileInfo fileInfo) {
|
||||
public CsvFileWriterService(FileInfo fileInfo) {
|
||||
textWriter = new StreamWriter(fileInfo.FullName);
|
||||
|
||||
csvWriter = new CsvWriter(textWriter, CultureInfo.InvariantCulture);
|
Loading…
Add table
Add a link
Reference in a new issue