Пример #1
0
 private static bool CheckLastLiterals(string s, string c, out int n)
 {
     return(VAR.CheckLast(s, c, out n) != -1 && s.Substring(n, s.Length - n).ToLower() == c);
 }
Пример #2
0
        public static object CheckLiterals(object o)
        {
            string str1 = o.ToString();

            if (str1.Check(true, bool.TrueString, bool.FalseString) != -1)
            {
                return((object)bool.Parse(str1));
            }
            int num1;

            if (VAR.CheckFirst(str1, "0x", out num1) == 0)
            {
                return((object)Convert.ToInt32(VAR.Convert(str1, num1 + 1), 16));
            }
            if (VAR.CheckFirst(str1, "0b", out num1) == 0)
            {
                return((object)Convert.ToInt32(VAR.Convert(str1, num1 + 1), 2));
            }
            if (VAR.CheckFirst(str1, "0o", out num1) == 0)
            {
                return((object)Convert.ToInt32(VAR.Convert(str1, num1 + 1), 8));
            }
            if (VAR.CheckFirst(str1, ".", out num1) != -1)
            {
                int  length = str1.Length;
                bool flag   = false;
                int  n;
                if (VAR.CheckLast(str1, "d", out n) != -1)
                {
                    --length;
                    flag = true;
                }
                else if (VAR.CheckLast(str1, "f", out n) != -1)
                {
                    --length;
                }
                if (VAR.CheckLast(str1, "e", out num1) != -1)
                {
                    string s = VAR.Convert(str1, num1);
                    if (length != str1.Length)
                    {
                        s = s.Substring(0, s.Length - 1);
                    }
                    float num2 = Mathf.Pow(10f, (float)int.Parse(s));
                    return(flag ? (object)(double.Parse(str1.Substring(0, num1)) * (double)num2) : (object)(float)((double)float.Parse(str1.Substring(0, num1)) * (double)num2));
                }
                return(flag ? (object)double.Parse(length != str1.Length ? str1.Substring(0, n) : str1) : (object)float.Parse(length != str1.Length ? str1.Substring(0, n) : str1));
            }
            if (VAR.CheckLast(str1, "d", out num1) != -1)
            {
                int    num2 = str1.Length - 1;
                string s1   = str1.Substring(0, num1);
                if (VAR.CheckLast(str1, "e", out num1) == -1)
                {
                    return((object)double.Parse(s1));
                }
                string str2 = VAR.Convert(str1, num1);
                string s2   = str2.Substring(0, str2.Length - 1);
                return((object)(double.Parse(str1.Substring(0, num1)) * (double)Mathf.Pow(10f, (float)int.Parse(s2))));
            }
            if (VAR.CheckLast(str1, "f", out num1) != -1)
            {
                int    num2 = str1.Length - 1;
                string s1   = str1.Substring(0, num1);
                if (VAR.CheckLast(str1, "e", out num1) == -1)
                {
                    return((object)float.Parse(s1));
                }
                string str2 = VAR.Convert(str1, num1);
                string s2   = str2.Substring(0, str2.Length - 1);
                return((object)(float)((double)float.Parse(str1.Substring(0, num1)) * (double)Mathf.Pow(10f, (float)int.Parse(s2))));
            }
            if (VAR.CheckLastLiterals(str1, "ul", out num1))
            {
                return((object)ulong.Parse(str1.Substring(0, num1)));
            }
            if (VAR.CheckLastLiterals(str1, "l", out num1))
            {
                return((object)long.Parse(str1.Substring(0, num1)));
            }
            if (VAR.CheckLastLiterals(str1, "u", out num1))
            {
                return((object)uint.Parse(str1.Substring(0, num1)));
            }
            if (VAR.CheckLastLiterals(str1, "m", out num1))
            {
                return((object)Decimal.Parse(str1.Substring(0, num1)));
            }
            if (VAR.CheckLast(str1, "e", out num1) != -1)
            {
                return((object)(float)((double)float.Parse(str1.Substring(0, num1)) * (double)Mathf.Pow(10f, (float)int.Parse(VAR.Convert(str1, num1)))));
            }
            if (str1[0] == '"' && str1[str1.Length - 1] == '"')
            {
                return((object)str1.Remove(str1.Length - 1, 1).Remove(0, 1));
            }
            return(int.TryParse(str1, out num1) ? (object)num1 : o);
        }