当前位置: 首页>>代码示例>>C#>>正文


C# ExpressionGenerator.WithType方法代码示例

本文整理汇总了C#中ExpressionGenerator.WithType方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionGenerator.WithType方法的具体用法?C# ExpressionGenerator.WithType怎么用?C# ExpressionGenerator.WithType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExpressionGenerator的用法示例。


在下文中一共展示了ExpressionGenerator.WithType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test001

        public void Test001()
        {
            var xgr = new ExpressionGenerator();
            var expr = Expression.Default(typeof(string));
            var expr2 = xgr.WithType<string>(expr);
            var expr3 = xgr.WithoutType(expr2);

            var xcr = new ExpressionComparer();
            Assert.IsTrue(xcr.AreEqual(expr, expr3));
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:10,代码来源:ExpressionGenerator.Tests.cs

示例2: Test003

        public void Test003()
        {
            var xgr = new ExpressionGenerator();
            var xc = new ExpressionComparer();

            var e2 = xgr.WithType<int>(Expression.Default(typeof(int)));
            var e3 = xgr.WithType<int>(Expression.Default(typeof(int)));

            var e1 = xgr.MakeEqualityComparison(e2, e3);

            var expected = Expression.Lambda<Func<bool>>(
                Expression.MakeBinary(
                    ExpressionType.Equal,
                    Expression.Default(typeof(int)),
                    Expression.Default(typeof(int))
                )
            );

            Assert.IsTrue(xc.AreEqual(expected, e1));
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:20,代码来源:ExpressionGenerator.MakeBinary.Tests.cs

示例3: Test093

        public void Test093()
        {
            var xgr = new ExpressionGenerator();
            var xc = new ExpressionComparer();

            var e2 = xgr.WithType<bool>(Expression.Default(typeof(bool)));
            var e3 = xgr.WithType<bool>(Expression.Default(typeof(bool)));

            var e1 = xgr.MakeOrElse(e2, e3);

            var expected = Expression.MakeBinary(
                ExpressionType.OrElse,
                Expression.Default(typeof(bool)),
                Expression.Default(typeof(bool))
            );

            Assert.IsTrue(xc.AreEqual(expected, e1));
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:18,代码来源:ExpressionGenerator.MakeBinary.Tests.cs

示例4: Test082

        public void Test082()
        {
            var xgr = new ExpressionGenerator();
            var xc = new ExpressionComparer();

            var e2 = xgr.WithType<bool?>(Expression.Default(typeof(bool?)));
            var e3 = xgr.WithType<bool>(Expression.Default(typeof(bool)));

            var e1 = xgr.MakeAndAlso(e2, e3);

            var expected = Expression.MakeBinary(
                ExpressionType.AndAlso,
                Expression.Default(typeof(bool?)),
                Expression.Convert(Expression.Default(typeof(bool)), typeof(bool?))
            );

            Assert.IsTrue(xc.AreEqual(expected, e1));
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:18,代码来源:ExpressionGenerator.MakeBinary.Tests.cs

示例5: Test073

        public void Test073()
        {
            var xgr = new ExpressionGenerator();
            var xc = new ExpressionComparer();

            var e2 = xgr.WithType<int>(Expression.Default(typeof(int)));
            var e3 = xgr.WithType<int>(Expression.Default(typeof(int)));

            var e1 = xgr.MakeBinary(e2, ExpressionType.Add, e3);

            var expected = Expression.MakeBinary(
                ExpressionType.Add,
                Expression.Default(typeof(int)),
                Expression.Default(typeof(int))
            );

            Assert.IsTrue(xc.AreEqual(expected, e1));
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:18,代码来源:ExpressionGenerator.MakeBinary.Tests.cs

示例6: Test039

        public void Test039()
        {
            var xgr = new ExpressionGenerator();

            var e2 = Expression.Default(typeof(bool));
            var e3 = Expression.Default(typeof(bool));
            var e4 = Expression.Default(typeof(bool));
            var e5 = Expression.Default(typeof(bool));
            var e1 = xgr.WithType<bool>(Expression.Or(e2, Expression.And(Expression.Or(e3, e4), e5)));

            var result = xgr.Split(e1, ExpressionType.And, ExpressionType.Or);

            Assert.AreEqual(4, result.Length);
            Assert.AreEqual(e2, result[0]);
            Assert.AreEqual(e3, result[1]);
            Assert.AreEqual(e4, result[2]);
            Assert.AreEqual(e5, result[3]);
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:18,代码来源:ExpressionGenerator.Tests.cs

示例7: Test032

        public void Test032()
        {
            var xgr = new ExpressionGenerator();

            var e2 = Expression.Default(typeof(bool));
            var e3 = Expression.Default(typeof(bool));
            var e1 = xgr.WithType<bool>(Expression.Or(e2, e3));

            var result = xgr.Split(e1, ExpressionType.And, ExpressionType.Or);

            Assert.AreEqual(2, result.Length);
            Assert.AreEqual(e2, result[0]);
            Assert.AreEqual(e3, result[1]);
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:14,代码来源:ExpressionGenerator.Tests.cs

示例8: Test014

        public void Test014()
        {
            var xgr = new ExpressionGenerator();

            var e2 = Expression.Default(typeof(bool));
            var e3 = Expression.Default(typeof(bool));
            var e4 = Expression.Default(typeof(bool));
            var e1 = xgr.WithType<bool>(Expression.And(Expression.And(e2, e3), e4));

            var result = xgr.Split(e1, ExpressionType.And);

            Assert.AreEqual(3, result.Length);
            Assert.AreEqual(e2, result[0]);
            Assert.AreEqual(e3, result[1]);
            Assert.AreEqual(e4, result[2]);
        }
开发者ID:hannasm,项目名称:ExpressiveExpressionTreesDotNet,代码行数:16,代码来源:ExpressionGenerator.Tests.cs


注:本文中的ExpressionGenerator.WithType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。