Use Guid.TryParse when available

This commit is contained in:
Yoshi Askharoun
2022-08-07 19:42:35 -05:00
parent 5ea10e7a4d
commit 421515ddbb
+8
View File
@@ -12,8 +12,15 @@ namespace ZuneUI
{
public static Guid CreateFromString(string value)
{
#if NET40_OR_GREATER || OPENZUNE
if (Guid.TryParse(value, out var guid))
return guid;
return Guid.Empty;
#else
if (string.IsNullOrEmpty(value))
return Guid.Empty;
Guid guid = Guid.Empty;
try
{
@@ -23,6 +30,7 @@ namespace ZuneUI
{
}
return guid;
#endif
}
public static bool IsEmpty(Guid guid) => guid == Guid.Empty;