mirror of https://github.com/winsw/winsw
Update YamlConfigurations.cs
parent
24131906ac
commit
d489020134
|
@ -1,13 +1,15 @@
|
||||||
using System;
|
namespace winsw.Configuration
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace winsw.Configuration
|
|
||||||
{
|
{
|
||||||
public class YamlConfiguration
|
public class YamlConfiguration
|
||||||
{
|
{
|
||||||
readonly ServiceAccount? serviceAccount;
|
public string? id { get; set; }
|
||||||
readonly BasicConfigs? basicConfigs;
|
public string? name { get; set; }
|
||||||
|
public string? description { get; set; }
|
||||||
|
public string? executable { get; set; }
|
||||||
|
public string? workingdirectory { get; set; }
|
||||||
|
|
||||||
|
public ServiceAccount? serviceaccount { get; set; }
|
||||||
|
public Log? log { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ServiceAccount
|
public class ServiceAccount
|
||||||
|
@ -18,11 +20,13 @@ namespace winsw.Configuration
|
||||||
public string allowservicelogon { get; set; }
|
public string allowservicelogon { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BasicConfigs
|
public class Log
|
||||||
{
|
{
|
||||||
public string id { get; set; }
|
public string sizeThreshold { get; set; }
|
||||||
public string name { get; set; }
|
public string keepFiles { get; set; }
|
||||||
public string description { get; set; }
|
public string pattern { get; set; }
|
||||||
public string executable { get; set; }
|
public string autoRollAtTime { get; set; }
|
||||||
|
public string period { get; set; }
|
||||||
|
public string mod { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using winsw.Configuration;
|
using winsw.Configuration;
|
||||||
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace winsw
|
namespace winsw
|
||||||
{
|
{
|
||||||
public class ServiceDescriptorYaml
|
public class ServiceDescriptorYaml
|
||||||
{
|
{
|
||||||
|
protected readonly YamlConfiguration configurations = new YamlConfiguration();
|
||||||
|
|
||||||
public static DefaultWinSWSettings Defaults { get; } = new DefaultWinSWSettings();
|
public static DefaultWinSWSettings Defaults { get; } = new DefaultWinSWSettings();
|
||||||
|
|
||||||
public string BasePath { get; set; }
|
public string BasePath { get; set; }
|
||||||
|
@ -24,11 +27,11 @@ namespace winsw
|
||||||
DirectoryInfo d = new DirectoryInfo(Path.GetDirectoryName(p));
|
DirectoryInfo d = new DirectoryInfo(Path.GetDirectoryName(p));
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (File.Exists(Path.Combine(d.FullName, baseName + ".yaml")))
|
if (File.Exists(Path.Combine(d.FullName, baseName + ".yml")))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (d.Parent is null)
|
if (d.Parent is null)
|
||||||
throw new FileNotFoundException("Unable to locate " + baseName + ".yaml file within executable directory or any parents");
|
throw new FileNotFoundException("Unable to locate " + baseName + ".yml file within executable directory or any parents");
|
||||||
|
|
||||||
d = d.Parent;
|
d = d.Parent;
|
||||||
}
|
}
|
||||||
|
@ -36,14 +39,13 @@ namespace winsw
|
||||||
BaseName = baseName;
|
BaseName = baseName;
|
||||||
BasePath = Path.Combine(d.FullName, BaseName);
|
BasePath = Path.Combine(d.FullName, BaseName);
|
||||||
|
|
||||||
using(var reader = new StreamReader(BasePath + ".yaml"))
|
using(var reader = new StreamReader(BasePath + ".yml"))
|
||||||
{
|
{
|
||||||
var file = reader.ReadToEnd();
|
var file = reader.ReadToEnd();
|
||||||
Console.WriteLine(file);
|
var deserializer = new DeserializerBuilder().Build();
|
||||||
}
|
|
||||||
|
|
||||||
// yaml <> object - deserialization and schema validation
|
configurations = deserializer.Deserialize<YamlConfiguration>(file);
|
||||||
// Set environment data
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue