Update yaml extension support

Improve error messages
improve boolean parser
remove unncessary logs
pull/638/head
Buddhika Chathuranga 2020-08-18 23:11:17 +05:30 committed by NextTurn
parent 362ea03104
commit 9f7047012a
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
5 changed files with 18 additions and 8 deletions

View File

@ -280,7 +280,6 @@ namespace WinSW
Log.Info("Starting " + this.descriptor.Executable + ' ' + startArguments);
// Load and start extensions
Console.WriteLine("Loading extensinos");
this.ExtensionManager.LoadExtensions();
this.ExtensionManager.FireOnWrapperStarted();

View File

@ -648,16 +648,27 @@ namespace WinSW.Configuration
{
get
{
int extensionNumber = 1;
if (this.YamlExtensionsConfiguration is null)
{
return new List<string>(0);
}
var result = new List<string>();
var result = new List<string>(this.YamlExtensionsConfiguration.Count);
foreach (var item in this.YamlExtensionsConfiguration)
{
result.Add(item.GetId());
try
{
result.Add(item.GetId());
}
catch (InvalidDataException)
{
throw new InvalidDataException("Id is null in Extension " + extensionNumber);
}
extensionNumber++;
}
return result;

View File

@ -22,7 +22,7 @@ namespace WinSW.Configuration
{
if (this.ExtensionId is null)
{
throw new InvalidDataException("Extension Id can't be empty");
throw new InvalidDataException();
}
return this.ExtensionId;
@ -32,7 +32,7 @@ namespace WinSW.Configuration
{
if (this.ExtensionClassName is null)
{
throw new InvalidDataException("Extension ClassName can't be empty");
throw new InvalidDataException($@"Extension ClassName is empty in extension {this.GetId()}");
}
return this.ExtensionClassName;
@ -42,7 +42,7 @@ namespace WinSW.Configuration
{
if (this.Settings is null)
{
throw new InvalidDataException("Extension settings not found");
throw new InvalidDataException(@$"Extension settings is empty in extension {this.GetId()}");
}
return this.Settings;

View File

@ -33,7 +33,7 @@ namespace WinSW.Extensions
/// <summary>
/// Configure the extension from Yaml configuration
/// </summary>
/// <param name="descriptor">Yaml Service Descptor</param>
/// <param name="descriptor">YamlConfiguration</param>
/// <param name="config">Configuration Node</param>
void Configure(IWinSWConfiguration descriptor, YamlExtensionConfiguration config);

View File

@ -38,7 +38,7 @@ namespace WinSW.Util
{
value = value.ToLower();
if (value.Equals("true") || value.Equals("yes") || value.Equals("on"))
if (value.Equals("true") || value.Equals("yes") || value.Equals("on") || value.Equals("y") || value.Equals("1"))
{
return true;
}