示例#1
0
        /// <summary>
        /// Generates an <see cref="Expression"/> node from a collection of input arguments.
        /// The result can be chained with other builders in a workflow.
        /// </summary>
        /// <param name="arguments">
        /// A collection of <see cref="Expression"/> nodes that represents the input arguments.
        /// </param>
        /// <returns>An <see cref="Expression"/> tree node.</returns>
        public override Expression Build(IEnumerable <Expression> arguments)
        {
            if (buildContext == null)
            {
                throw new InvalidOperationException("No valid build context was provided.");
            }

            var source            = arguments.First();
            var subjectFactory    = BuildSubject(source);
            var parameterType     = source.Type.GetGenericArguments()[0];
            var subjectExpression = buildContext.AddVariable(Name, subjectFactory);

            return(Expression.Call(typeof(SubjectBuilder), "Process", new[] { parameterType }, source, subjectExpression));
        }
示例#2
0
 public ParameterExpression AddVariable(string name, Expression expression)
 {
     return(parent.AddVariable(name, expression));
 }