Exemplo n.º 1
0
        protected override Expression VisitConstant(ConstantExpression node)
        {
            Token token;

            if (node.Value == null)
            {
                token = new Token
                {
                    TokenType = TokenType.Null,
                    Value     = "null"
                };
            }
            else
            {
                token = new Token
                {
                    TokenType = LiteralTokenTypes.Lookup(node.Type),
                    Value     = _typeFormatter.Format(node.Type, node.Value)
                };
            }

            _expression.Push(token);

            return(base.VisitConstant(node));
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            var result = (Value == null)
                                ? "Null"
                                : Formatter.Format(Type, Value);

            return(result);
        }
Exemplo n.º 3
0
        public void WriteRow([NotNull] T value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var values = _formatter.Format(value);

            _writer.WriteRow(values);
        }
Exemplo n.º 4
0
        public void Format_NullType_ThrowsException()
        {
            var value = "HelloWorld";

            Assert.That(() => _formatter.Format(null, value), Throws.Exception);
        }
        public void Format_NullType_ThrowsException()
        {
            var value = DateTimeOffset.Now;

            Assert.That(() => _formatter.Format(null, value), Throws.Exception);
        }
Exemplo n.º 6
0
        public void Format_NullType_ThrowsException()
        {
            var value = Guid.NewGuid();

            Assert.That(() => _formatter.Format(null, value), Throws.Exception);
        }
 public static string Format <T>(this ITypeFormatter formatter, T value)
 {
     return(formatter.Format(typeof(T), value));
 }
Exemplo n.º 8
0
 public static void Format(this ITypeFormatter formatter, object instance, TextWriter writer)
 {
     formatter.Format(new FormatContext(), instance, writer);
 }
Exemplo n.º 9
0
        public void Format_NullType_ThrowsException()
        {
            var value = typeof(string);

            Assert.That(() => _formatter.Format(null, value), Throws.Exception);
        }