Esempio n. 1
0
        internal static (long, bool) convertToInteger(object val)
        {
            switch (val.GetType().Name)
            {
            case "Int64": return((long)val, true);

            case "Double": return(Math.FloatToInteger((double)val));

            case "String": return(Convert.ToInt64(val), true);

            default: return(0L, false);
            }
        }
Esempio n. 2
0
        internal static (long, bool) ConvertToInteger(object val)
        {
            switch (val)
            {
            case long l: return(l, true);

            case double d: return(Math.FloatToInteger(d));

            case string _: return(Convert.ToInt64(val), true);

            default: return(0L, false);
            }
        }
Esempio n. 3
0
        private (long, bool) _stringToInteger(string s)
        {
            var v = Parser.ParseInteger(s);

            if (v.Item2)
            {
                return(v.Item1, true);
            }

            var v2 = Parser.ParseFloat(s);

            if (v2.Item2)
            {
                return(Math.FloatToInteger(v2.Item1));
            }

            return(0L, false);
        }