Ejemplo n.º 1
0
        public Completion Execute(ExecutionEnvironment enviroment)
        {
            if (Raw == null)
            {
                return(new Completion(null));
            }
            int     intValue    = 0;
            float   floatValue  = 0;
            double  doubleValue = 0;
            Boolean b           = false;

            if (int.TryParse(Raw, out intValue))
            {
                return(new Completion(intValue));
            }
            if (float.TryParse(Raw, out floatValue))
            {
                return(new Completion(floatValue));
            }
            if (double.TryParse(Raw, out doubleValue))
            {
                return(new Completion(doubleValue));
            }
            if (Boolean.TryParse(Raw, out b))
            {
                return(new Completion(b));
            }
            if (Raw.StartsWith("\"") && Raw.EndsWith("\""))
            {
                return(new Completion(Raw.Substring(1, Raw.Length - 2)));
            }
            return(Completion.Exception(Raw + " is not valid", this));
        }
Ejemplo n.º 2
0
        protected override Completion ExecuteImpl(ExecutionEnvironment enviroment)
        {
            if (Raw == null)
            {
                return(new Completion(null));
            }
            int    intValue;
            float  floatValue;
            double doubleValue;
            bool   b;

            if (Raw.StartsWith("\"") && Raw.EndsWith("\""))
            {
                string str = GetStringLateral(Raw.Substring(1, Raw.Length - 2));
                return(new Completion(str));
            }
            if (Raw.StartsWith("'") && Raw.EndsWith("'") && Raw.Length == 3)
            {
                return(new Completion(Raw[1]));
            }
            if (Raw.StartsWith("0x", StringComparison.CurrentCultureIgnoreCase) ||
                Raw.StartsWith("&H", StringComparison.CurrentCultureIgnoreCase))
            {
                string hex = Raw.Substring(2);
                uint   uintValue;
                if (uint.TryParse(hex, System.Globalization.NumberStyles.HexNumber, CultureInfo.CurrentCulture, out uintValue))
                {
                    return(new Completion(uintValue));
                }
            }
            if (Raw.Equals("true", StringComparison.CurrentCultureIgnoreCase))
            {
                return(new Completion(true));
            }
            if (Raw.Equals("false", StringComparison.CurrentCultureIgnoreCase))
            {
                return(new Completion(false));
            }
            if (Raw.Equals("null", StringComparison.CurrentCultureIgnoreCase))
            {
                return(new Completion(null));
            }
            if (int.TryParse(Raw, out intValue))
            {
                return(new Completion(intValue));
            }
            if (float.TryParse(Raw, out floatValue))
            {
                return(new Completion(floatValue));
            }
            if (double.TryParse(Raw, out doubleValue))
            {
                return(new Completion(doubleValue));
            }
            if (Boolean.TryParse(Raw, out b))
            {
                return(new Completion(b));
            }
            //if (enviroment.HasValue(Raw))
            //    return new Completion(enviroment.GetValue(Raw));
            return(Completion.Exception(string.Format(Properties.Language.InvalidFormat, Raw), this));
        }