Ejemplo n.º 1
0
        public RemoveAction(RemoveActionConfiguration configuration, IExpressionBuilder expressionBuilder, IMatchValueExtractor matchValueExtractor)
        {
            this.configuration       = configuration;
            this.matchValueExtractor = matchValueExtractor;

            find = expressionBuilder.Build(configuration.Expression);
        }
Ejemplo n.º 2
0
        public ReplaceAction(ReplaceActionConfiguration configuration, IExpressionBuilder expressionBuilder, IMatchValueExtractor matchValueExtractor)
        {
            this.configuration       = configuration;
            this.matchValueExtractor = matchValueExtractor;

            find        = expressionBuilder.Build(configuration.Expression);
            replaceWith = new Regex("\\${(?<name>.*?)}", RegexOptions.ExplicitCapture | RegexOptions.Compiled);
        }
Ejemplo n.º 3
0
        protected override ExecutionResult ExecuteCore()
        {
            var expression = builder.Build(TransformedExpression);

            Command.Result = expression.Evaluate();

            return(new ExecutionResult("Success"));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Calculates the given infix string. Throws if input is invalid
        /// </summary>
        /// <exception cref="ArgumentException"></exception>
        /// <param name="input"></param>
        /// <returns>The calculated value of the input</returns>
        public int CalculateExpression(string input)
        {
            var infix = input.Replace(" ", string.Empty);

            if (_tokenizer.IsValid(infix))
            {
                infix = _tokenizer.Tokenize(infix);
                var postfix    = _infixToPostfixConverter.InFixToPostFix(infix);
                var expression = _expressionBuilder.Build(postfix.ToArray());
                return(expression.Interpret());
            }

            throw new ArgumentException("Not a valid input");
        }
Ejemplo n.º 5
0
        public override Action ProcessToken(IParseResult token, Stack <IParseResult> resultTokens, IOutputProcessor outputProcessor)
        {
            ProcessedTokenCount++;

            var result = ( ExpressionParseResult )resultTokens.Pop();

            if (resultTokens.Any())
            {
                throw new FinalizationException("Finalization was attempted before processing has completed");
            }

            string expressionDisplay = _expressionBuilder.Build(result, false);

            return(outputProcessor.Write(result.Result.Result, expressionDisplay));
        }
Ejemplo n.º 6
0
        private CloneDelegate <TEntity> AssembleExpression <TEntity>(IExpressionBuilder expressionBuilder)
            where TEntity : class
        {
            CloneExpressionContext context = new CloneExpressionContext
            {
                SourceEntity = expressionBuilder.AddParameter <TEntity>(nameof(CloneExpressionContext.SourceEntity)),
                CloneFactory = expressionBuilder.AddParameter <ICloneFactory>(nameof(CloneExpressionContext.CloneFactory)),
            };

            if (CollectionTypes.Any(collectionType => IsCollectionType(collectionType, typeof(TEntity))))
            {
                AddCollectionExpressions <TEntity>(expressionBuilder, context);
            }
            else
            {
                AddCloneExpressions <TEntity>(expressionBuilder, context);
            }

            expressionBuilder.ReturnObject(context.TargetEntity);

            return(expressionBuilder.Build <CloneDelegate <TEntity> >());
        }
Ejemplo n.º 7
0
 public static void Verify <T>(this Mock <T> mock, IExpressionBuilder builder, Times times) where T : class, ILogger
 {
     mock.Verify(builder.Build <T>(), times);
 }
Ejemplo n.º 8
0
 public static void Verify <T>(this T mocked, IExpressionBuilder builder, Times times) where T : class, ILogger
 {
     Mock.Get(mocked).Verify(builder.Build <T>(), times);
 }
Ejemplo n.º 9
0
 public ConditionsMatcher(ConditionsConfiguration conditionsConfiguration, IExpressionBuilder expressionBuilder, IMatchValueExtractor matchValueExtractor)
 {
     this.conditionsConfiguration = conditionsConfiguration;
     this.matchValueExtractor     = matchValueExtractor;
     expression = expressionBuilder.Build(conditionsConfiguration.Expression);
 }
Ejemplo n.º 10
0
 public MultiLineFilter(MultiLineFilterConfiguration configuration, IExpressionBuilder expressionBuilder)
 {
     expression = expressionBuilder.Build(configuration.Conditions.Expression);
 }