Use the Enum functions for string-to-enum and enum-to-string conversions

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2015-09-11 11:55:51 +01:00
parent 50176afc14
commit fc75ceb4ce

View File

@ -377,28 +377,15 @@ namespace XenAdmin.Model
internal static DiagnosticAlertSeverity StringToDiagnosticAlertSeverity(string severity)
{
switch (severity)
{
case "Error":
return DiagnosticAlertSeverity.Error;
case "Warning":
return DiagnosticAlertSeverity.Warning;
default:
return DiagnosticAlertSeverity.Info;
}
DiagnosticAlertSeverity result;
if (Enum.TryParse(severity, out result))
return result;
return DiagnosticAlertSeverity.Info;
}
internal static string DiagnosticAlertSeverityToString(DiagnosticAlertSeverity severity)
{
switch (severity)
{
case DiagnosticAlertSeverity.Error:
return "Error";
case DiagnosticAlertSeverity.Warning:
return "Warning";
default:
return "Info";
}
return severity.ToString();
}
}
}