17 lines
455 B
C#
Raw Normal View History

// Copyright (c) Microsoft. All rights reserved.
namespace DevTeam;
2024-06-19 17:25:18 -07:00
public static class ParseExtensions
{
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;
}
}