internal static bool TryLong()

in src/PSDocs/Common/ExpressionHelpers.cs [216:246]


        internal static bool TryLong(object o, bool convert, out long value)
        {
            o = GetBaseObject(o);
            if (o is byte b)
            {
                value = b;
                return true;
            }
            else if (o is int i)
            {
                value = i;
                return true;
            }
            else if (o is long l)
            {
                value = l;
                return true;
            }
            else if (o is JToken token && token.Type == JTokenType.Integer)
            {
                value = token.Value<long>();
                return true;
            }
            else if (convert && TryString(o, out string s) && long.TryParse(s, out l))
            {
                value = l;
                return true;
            }
            value = default(long);
            return false;
        }