コード例 #1
0
        public IExpressionTree <TClass> ParseTree <TClass>(params LambdaExpression[] lambdas)
        {
            var chains = lambdas.Select(lambda => ExpressionChainExtractor.AsExpressionChain(lambda));

            return(new ExpressionTree <TClass> {
                Children = ChainsToTree(chains).ToList()
            });
        }
コード例 #2
0
        public void ExpressionToChain1()
        {
            Expression <Func <Department, User> > lambda = u => u.Head;
            var chain = ExpressionChainExtractor.AsExpressionChain(lambda);

            Assert.Equal(nameof(Department.Head), chain.Current.Name);

            Assert.True(new ExpressionEqualityComparer().Equals(lambda, chain.ToLambdaExpression()));
        }
コード例 #3
0
        public void ExpressionToChain2()
        {
            Expression <Func <Department, IEnumerable <int> > > lambda = u => u.Head.Collaborators.Select(c => c.Id);
            var chain = ExpressionChainExtractor.AsExpressionChain(lambda);

            Assert.Equal(nameof(Department.Head), chain.Current.Name);
            Assert.Equal(nameof(User.Collaborators), chain.Next.Current.Name);
            Assert.Equal(nameof(User.Id), chain.Next.Next.Current.Name);

            Assert.True(new ExpressionEqualityComparer().Equals(lambda, chain.ToLambdaExpression()));
        }
コード例 #4
0
 public IExpressionChain <TClass> ParseChain <TClass, TProp>(Expression <Func <TClass, TProp> > lambda)
 => ExpressionChainExtractor.AsExpressionChain(lambda);
コード例 #5
0
 public IExpressionChain ParseChain(LambdaExpression lambda)
 => ExpressionChainExtractor.AsExpressionChain(lambda);