Change Supported to Enum

This commit is contained in:
Matt Nadareski
2020-08-22 13:31:13 -07:00
parent b30173ba55
commit d4be402380
9 changed files with 196 additions and 68 deletions

View File

@@ -819,6 +819,37 @@ namespace SabreTools.Library.Tools
#endif
}
/// <summary>
/// Get Supported value from input string
/// </summary>
/// <param name="supported">String to get value from</param>
/// <returns>Supported value corresponding to the string</returns>
public static Supported AsSupported(this string supported)
{
#if NET_FRAMEWORK
switch (supported?.ToLowerInvariant())
{
case "no":
return Supported.No;
case "partial":
return Supported.Partial;
case "yes":
return Supported.Yes;
default:
return Supported.NULL;
}
#else
return supported?.ToLowerInvariant() switch
{
"no" => Supported.No,
"partial" => Supported.Partial,
"yes" => Supported.Yes,
_ => Supported.NULL,
};
#endif
}
/// <summary>
/// Get bool? value from input string
/// </summary>