16 lines
432 B
C#
Raw Normal View History

2024-06-19 17:25:18 -07:00
namespace Microsoft.AI.DevTeam.Extensions;
public static class ParseExtensions
{
2024-06-19 17:25:18 -07:00
public static long TryParseLong(this Dictionary<string, string> data, string key)
{
2024-06-19 17:25:18 -07:00
ArgumentNullException.ThrowIfNull(data);
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-06-19 17:25:18 -07:00
return default;
}
}