Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AutoEntityGenerator/AutoEntityGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
<LangVersion>latests</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
28 changes: 12 additions & 16 deletions AutoEntityGenerator/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace AutoEntityGenerator
internal class ConfigurationService : IConfigurationSaver
{
private const string FileName = "appSettings.json";
private const string DefaultDestinationFolder = "Generated";
private readonly string _basePath;
private readonly string _fullFilePath;
private readonly JsonSerializerOptions _jsonOptions;
Expand All @@ -30,8 +31,17 @@ public ConfigurationService()
}

public IAppSettings Load()
=> LoadFromFile() ?? new AppSettings()
{
DestinationFolder = DefaultDestinationFolder,
MinimumLogLevel = LogLevel.Information,
RequestSuffix = "Request",
ResponseSuffix = "Response",
OpenGeneratedFiles = true
};

private IAppSettings LoadFromFile()
{
const string DefaultDestinationFolder = "Generated";
IAppSettings settings = null;
if (File.Exists(_fullFilePath))
{
Expand All @@ -53,24 +63,10 @@ public IAppSettings Load()
_deferredException = ex;
}
}

if (settings is null)
{
settings = new AppSettings()
{
DestinationFolder = DefaultDestinationFolder,
MinimumLogLevel = LogLevel.Information,
RequestSuffix = "Request",
ResponseSuffix = "Response",
OpenGeneratedFiles = true
};
}


return settings;
}

// TO Consider: Moving validation from UI to common to reduce code repitition.
// TO Consider: Move validation from UI to common to reduce code repitition.
private bool IsDestinationFolderValid(string destinationFolder)
{
return !destinationFolder.Any(c => Path.GetInvalidPathChars().Contains(c)) &&
Expand Down
2 changes: 1 addition & 1 deletion AutoEntityGenerator/Services.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void ConfigureServices()
.AddUI();
}

// TO Consider: Switch to using Visual studio's Activity log instead.
// TO Consider: Switch to using file based log: Serilog / Nlog / Visual studio's Activity log.
private Services AddLogger()
{
const string sourceName = nameof(AutoEntityGenerator);
Expand Down
Loading