Ejemplo n.º 1
0
        public static ExpressionValue GetValueFromText(IList <Char> chars)
        {
            if (chars == null)
            {
                return(null);
            }

            if (StringHelper.IsString(chars, '\''))
            {
                var name = StringHelper.ToString2(chars);
                return(new ExpressionValue(
                           name.Substring(1, name.Length - 2).Replace("\\'", "'")));
            }
            else if (StringHelper.IsInteger(chars))
            {
                return(new ExpressionValue(
                           UniConvert.ParseUniInt64(StringHelper.ToString2(StringHelper.Replace2(chars, ',', '.')))));
            }
            else if (StringHelper.IsNumber(chars))
            {
                return(new ExpressionValue(
                           UniConvert.ParseUniDecimal(StringHelper.ToString2(StringHelper.Replace2(chars, ',', '.')))));
            }
            else if (StringHelper.SequenceEqualInsensitive(chars, OperatorTypeHelper.symbol_null))
            {
                return(new ExpressionValue(null));
            }
            else if (StringHelper.SequenceEqualInsensitive(chars, OperatorTypeHelper.symbol_false))
            {
                return(new ExpressionValue(false));
            }
            else if (StringHelper.SequenceEqualInsensitive(chars, OperatorTypeHelper.symbol_true))
            {
                return(new ExpressionValue(true));
            }
            else if (StringHelper.SequenceEqual(chars, OperatorTypeHelper.symbol_new_line))
            {
                return(new ExpressionValue("\r\n"));
            }
            else if (StringHelper.SequenceEqualInsensitive(chars, OperatorTypeHelper.symbol_undefined))
            {
                return(new ExpressionValue(new Undefined()));
            }
            return(null);
        }