cssitegen/ProjectSettings/ProjectSettings.cs
Robert Morrison 34bf088c78
refactor: Merge Project/Runtime Settings
Merge the RuntimeSettings class into ProjectSettings,
Minimising the duplication of stored data
2024-06-03 02:54:38 +01:00

48 lines
1.3 KiB
C#

using System.Text.Json.Serialization;
// project settings is a user accessible config to set the Source and destination of a site
// This may include more scope in the future such as holding the site base address etc..
public class ProjectSettings
{
// The Source and Destination need to be public for the json constructor to work properly.
public string Source {get; private set;}
public string Destination {get; private set;}
private DirectoryInfo? _ProjectRoot;
public string? BaseUrl {get; private set;}
public DirectoryInfo InputDirectory {get {
if (_ProjectRoot is null)
{
return new(Source);
}
return new(Path.Combine(_ProjectRoot.FullName,Source));
}}
public DirectoryInfo OutputDirectory {get {
if (_ProjectRoot is null)
{
return new(Destination);
}
return new(Path.Combine(_ProjectRoot.FullName,Destination));
}}
[JsonConstructor]
public ProjectSettings(String source, String destination, string baseUrl) {
Source = source;
Destination = destination;
BaseUrl = baseUrl;
}
public void setProjectRoot(string projectRoot) {
_ProjectRoot = new(projectRoot);
}
public void setProjectRoot(DirectoryInfo projectRoot) {
_ProjectRoot = projectRoot;
}
/*
* public void setBaseUrl(string baseUrl) {
* BaseUrl = baseUrl;
* }
*/
}