internal LiftWildcards(ReifiedOperation operation, IWildcardGenerator generator) : base(ReifiedOperationKind.LiftWildcards, operation) { Generator = generator ?? throw new ArgumentNullException(nameof(generator)); }
protected override Expression <Action <TEnvironment> > MakeLiftWildcards(Expression <Action <TEnvironment> > operation, IWildcardGenerator generator) { var parameter = operation.Parameters[0]; var wildcardSubstitutor = new WildcardParameterSubstitutor(); var substitutedOperation = wildcardSubstitutor.Visit(operation.Body); var generateExpr = Expression.Invoke(s_generateExpr, Expression.Constant(generator, typeof(IWildcardGenerator))).BetaReduce(); var assignments = wildcardSubstitutor.Wildcards.Select(p => Expression.Assign(p, generateExpr)); return(Expression.Lambda <Action <TEnvironment> >( Expression.Block( wildcardSubstitutor.Wildcards, assignments.EndWith(substitutedOperation) ), parameter )); }
/// <summary> /// Remaps all the wildcards in an operation to identifiers taken from the wildcard generator. /// </summary> /// <param name="operation">The operation.</param> /// <param name="generator">The wildcard generator.</param> /// <returns>The wrapped operation.</returns> public static ReifiedOperation LiftWildcards(this ReifiedOperation operation, IWildcardGenerator generator) { if (operation == null) { throw new ArgumentNullException(nameof(operation)); } if (generator == null) { throw new ArgumentNullException(nameof(generator)); } return(new LiftWildcards(operation, generator)); }