public void Visit(FloatLiteral op)
 {
     WriteEncoded(_context.Format(op.Value));
     if (_version.OnlySupportsV2OrV3())
     {
         WriteEncoded("d");
     }
 }
Exemple #2
0
        public virtual void Visit(FloatLiteral op)
        {
            var str = Context.Format(op.Value);

            if (str.IndexOf('.') < 0)
            {
                str += ".0";
            }
            Writer.Write(str);
        }
 public static bool TryGetNumberLiteral(string value, out ILiteral literal)
 {
     if (long.TryParse(value, out long lng))
     {
         literal = new IntegerLiteral(lng);
         return(true);
     }
     else if (double.TryParse(value, out double dbl))
     {
         literal = new FloatLiteral(dbl);
         return(true);
     }
     literal = null;
     return(false);
 }
 public virtual void Visit(FloatLiteral op)
 {
 }
 public void Visit(FloatLiteral op)
 {
     _conditionWriter.WriteElementString("constant", _context.Format(op.Value));
 }
 public virtual IExpression Clone(FloatLiteral op)
 {
     return(new FloatLiteral(op.Value));
 }
 void IExpressionVisitor.Visit(FloatLiteral op)
 {
     _clone = Clone(op);
 }
        public static bool TryGetLiteral(object value, out ILiteral literal)
        {
            literal = null;
            if (value is bool b)
            {
                literal = new BooleanLiteral(b);
            }
            else if (value is byte by)
            {
                literal = new IntegerLiteral(by);
            }
            else if (value is sbyte sb)
            {
                literal = new IntegerLiteral(sb);
            }
            else if (value is short sh)
            {
                literal = new IntegerLiteral(sh);
            }
            else if (value is ushort us)
            {
                literal = new IntegerLiteral(us);
            }
            else if (value is int i)
            {
                literal = new IntegerLiteral(i);
            }
            else if (value is uint ui)
            {
                literal = new IntegerLiteral(ui);
            }
            else if (value is long l)
            {
                literal = new IntegerLiteral(l);
            }
            else if (value is ulong ul)
            {
                literal = new IntegerLiteral((long)ul);
            }
            else if (value is float f)
            {
                literal = new FloatLiteral(f);
            }
            else if (value is double d)
            {
                literal = new FloatLiteral(d);
            }
            else if (value is DateTime dt)
            {
                literal = new DateTimeLiteral(dt);
            }
            else if (value is Guid g)
            {
                literal = new StringLiteral(g.ToArasId());
            }
            else if (value is string str)
            {
                literal = new StringLiteral(str);
            }
            else
            {
                return(false);
            }

            return(true);
        }