コード例 #1
0
        public void NoOperatorClass()
        {
            var valueLeft  = new NoOpClass();
            var valueRight = new NoOpClass();

            AssertEx.Throws <InvalidOperationException>(() => Expression.And(Expression.Constant(valueLeft), Expression.Constant(valueRight)));
        }
コード例 #2
0
        public void Rank1UserDefinedClass()
        {
            var       value = new NoOpClass();
            const int Index = 0;
            var       type  = typeof(NoOpClass);

            NoOpClass[] array = { value };

            var binaryExpression = Expression.ArrayIndex(Expression.Constant(array), Expression.Constant(Index));

            Assert.AreEqual(ExpressionType.ArrayIndex, binaryExpression.NodeType, "ArrayIndex#05");
            Assert.AreEqual(type, binaryExpression.Type, "ArrayIndex#06");
            Assert.IsNull(binaryExpression.Method, "ArrayIndex#07");
            Assert.AreEqual($"value({type.FullName}[])[{Index}]", binaryExpression.ToString(), "ArrayIndex#08");
        }
コード例 #3
0
        public void Rank2UserDefinedClass()
        {
            var       ValueA = new NoOpClass();
            var       ValueB = new NoOpClass();
            const int IndexA = 1;
            const int IndexB = 0;
            var       type   = typeof(NoOpClass);

            NoOpClass[,] array = { { ValueA }, { ValueB } };
            Expression[] indexes = { Expression.Constant(IndexA), Expression.Constant(IndexB) };

            var binaryExpression = Expression.ArrayIndex(Expression.Constant(array), indexes);

            Assert.AreEqual(ExpressionType.Call, binaryExpression.NodeType, "ArrayIndex#13");
            Assert.AreEqual(type, binaryExpression.Type, "ArrayIndex#14");
            Assert.AreEqual($"value({type.FullName}[,]).Get(1, 0)", binaryExpression.ToString(), "ArrayIndex#16");
        }