2024-09-17 09:01:49 -04:00
|
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
|
|
|
|
namespace DevTeam;
|
2024-06-19 17:25:18 -07:00
|
|
|
|
|
|
|
public static class ParseExtensions
|
2024-05-23 17:38:34 +02:00
|
|
|
{
|
2024-09-17 09:01:49 -04:00
|
|
|
public static long TryParseLong(this Dictionary<string, string> data, string key)
|
2024-05-23 17:38:34 +02:00
|
|
|
{
|
2024-06-19 17:25:18 -07:00
|
|
|
ArgumentNullException.ThrowIfNull(data);
|
2024-05-23 17:38:34 +02:00
|
|
|
|
2024-06-19 17:25:18 -07:00
|
|
|
if (data.TryGetValue(key, out string? value) && !string.IsNullOrEmpty(value) && long.TryParse(value, out var result))
|
|
|
|
{
|
|
|
|
return result;
|
2024-05-23 17:38:34 +02:00
|
|
|
}
|
2024-06-19 17:25:18 -07:00
|
|
|
return default;
|
2024-05-23 17:38:34 +02:00
|
|
|
}
|
2024-09-17 09:01:49 -04:00
|
|
|
}
|