Пример #1
0
 public static void AsTypeExpr()
 {
     ExpressionTrees.Test((Func <object, MyClass>)((object obj) => obj as MyClass), (Expression <Func <object, MyClass> >)((object obj) => obj as MyClass));
     ExpressionTrees.Test((Func <object, GenericClass <object> >)((object obj) => obj as GenericClass <object>), (Expression <Func <object, GenericClass <object> > >)((object obj) => obj as GenericClass <object>));
 }
Пример #2
0
 public void NewMultiDimArray()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new int[3, 4].Length == 1);
 }
Пример #3
0
 public void Quoted()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => (Expression <Func <int, string, string> >)((int n, string s) => s + n.ToString()) != null);
 }
Пример #4
0
 private bool MyEquals(ExpressionTrees other)
 {
     throw new NotImplementedException();
 }
Пример #5
0
 public void MultipleDots()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => 3.ToString().ToString().Length > 0);
 }
Пример #6
0
 public void LiteralCharAndProperty()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new string(' ', 3).Length == 1);
 }
Пример #7
0
        public void NotImplicitCast()
        {
            byte z = 42;

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => ~z == 0);
        }
Пример #8
0
        public static void Capturing()
        {
            int captured = 5;

            ExpressionTrees.Test((Func <int>)(() => captured), (Expression <Func <int> >)(() => captured));
        }
Пример #9
0
 public static void Quote()
 {
     ExpressionTrees.Test((Func <bool>)(() => (Expression <Func <int, string, string> >)((int n, string s) => s + n.ToString()) != null), (Expression <Func <bool> >)(() => (Expression <Func <int, string, string> >)((int n, string s) => s + n.ToString()) != null));
 }
Пример #10
0
 public static void UnaryArithmeticOperators()
 {
     ExpressionTrees.Test((Func <int, int>)((int a) => a), (Expression <Func <int, int> >)((int a) => a));
     ExpressionTrees.Test((Func <int, int>)((int a) => - a), (Expression <Func <int, int> >)((int a) => - a));
 }
Пример #11
0
 public static void SimpleExpressions()
 {
     ExpressionTrees.Test((Func <int>)(() => 0), (Expression <Func <int> >)(() => 0));
     ExpressionTrees.Test((Func <int, int>)((int a) => a), (Expression <Func <int, int> >)((int a) => a));
 }
Пример #12
0
 public static void ConditionalOperator()
 {
     ExpressionTrees.ToCode(null, (bool a) => a ? 5 : 10);
     ExpressionTrees.ToCode(null, (object a) => a ?? new MyClass());
 }
Пример #13
0
 public static void UnaryLogicalOperators()
 {
     ExpressionTrees.Test((Func <bool, bool>)((bool a) => !a), (Expression <Func <bool, bool> >)((bool a) => !a));
 }
Пример #14
0
 public static void IsTypeExpr()
 {
     ExpressionTrees.Test((Func <object, bool>)((object obj) => obj is MyClass), (Expression <Func <object, bool> >)((object obj) => obj is MyClass));
 }
Пример #15
0
        public void IndexerAccess()
        {
            Dictionary <string, int> dict = Enumerable.Range(1, 20).ToDictionary((int n) => n.ToString());

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => dict["3"] == 3);
        }
Пример #16
0
 public void Parameter(bool a)
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => a);
 }
Пример #17
0
 public void IsOperator()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new object() is string);
 }
Пример #18
0
        public void LocalVariable()
        {
            bool a = true;

            ExpressionTrees.ToCode(ExpressionTrees.X(), () => a);
        }
Пример #19
0
 public void CharNoCast()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => "abc"[1] == 'b');
 }
Пример #20
0
 public void LambdaParameter()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), (bool a) => a);
 }
Пример #21
0
 public void DoAssert()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.field != this.C());
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => !object.ReferenceEquals(this, new ExpressionTrees()));
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => this.MyEquals(this) && !this.MyEquals(null));
 }
Пример #22
0
 public void AddOperator(int x)
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => 1 + x + 2);
 }
Пример #23
0
 public void MultipleCasts()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => 1 == (int)(object)1);
 }
Пример #24
0
 public void ComplexGenericName()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ((Func <int, bool>)((int x) => x > 0))(0));
 }
Пример #25
0
 public void CurriedLambda()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), (Expression <Func <int, Func <int, Func <int, int> > > >)((int a) => (int b) => (int c) => a + b + c));
 }
Пример #26
0
 public void DefaultValue()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new TimeSpan(1, 2, 3) == default(TimeSpan));
 }
Пример #27
0
 public void NewObject()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new object() != new object());
 }
Пример #28
0
 public void EnumConstant()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => new object().Equals(MidpointRounding.ToEven));
 }
Пример #29
0
 public void Quoted2()
 {
     ExpressionTrees.ToCode(ExpressionTrees.X(), () => ExpressionTrees.ToCode(ExpressionTrees.X(), () => true).Equals(null));
 }
Пример #30
0
 public static void ArrayLength()
 {
     ExpressionTrees.Test((Func <int[], int>)((int[] array) => array.Length), (Expression <Func <int[], int> >)((int[] array) => array.Length));
     ExpressionTrees.Test((Func <int>)(() => ((Array)null).Length), (Expression <Func <int> >)(() => ((Array)null).Length));
 }