Example #1
0
        public void Should_Convert_String_To_LongNullable()
        {
            var v1 = ConvertEx.ConvertTo("3", typeof(long?));
            var v2 = ConvertEx.Convert <long?>("3");

            Assert.True(v1 is long l1 && l1 == 3);
            Assert.True(v2 == 3);
        }
Example #2
0
        public void Should_Convert_Int_To_Long()
        {
            var v1 = ConvertEx.ConvertTo(3, typeof(long));
            var v2 = ConvertEx.Convert <long>(3);

            Assert.True(v1 is long l1 && l1 == 3);
            Assert.True(v2 == 3);
        }
Example #3
0
        public void Should_Convert_IntNullable_To_LongNullable()
        {
            int?i = 3;

            var v1 = ConvertEx.ConvertTo(i, typeof(long?));
            var v2 = ConvertEx.Convert <long?>(i);

            Assert.True(v1 is long l1 && l1 == 3);
            Assert.True(v2 == 3);
        }
Example #4
0
 protected override Expression VisitTypeBinary(TypeBinaryExpression node)
 {
     return(Expression.Constant(ConvertEx.ConvertTo(Evaluate(node.Expression).Value, node.TypeOperand)));
 }
Example #5
0
 public void Set(object instance, object value, object indexer1, object indexer2, object indexer3)
 {
     ValidateSetter();
     this.Setter(instance, ConvertEx.ConvertTo(value, this.Type), indexer1, indexer2, indexer3);
 }
Example #6
0
 public void Set(object instance, object[] indexers, object value)
 {
     ValidateSetter(indexers);
     this.Setter(instance, ConvertEx.ConvertTo(value, this.Type), indexers);
 }
Example #7
0
 public void Set(object value)
 {
     ValidateSetter(null, true);
     this.Setter(null, ConvertEx.ConvertTo(value, this.Type));
 }