Ejemplo n.º 1
0
        public ApplyElementProcessor(
            [NotNull] IConfigurationExpressionEvaluator configurationExpressionEvaluator,
            [NotNull] ITokenUsageTracker tokenUsageTracker)
            : base(tokenUsageTracker)
        {
            if (configurationExpressionEvaluator == null)
            {
                throw new ArgumentNullException(nameof(configurationExpressionEvaluator));
            }

            _configurationExpressionEvaluator = configurationExpressionEvaluator;
        }
 public ApplyWhenAttributeProcessor(
     [NotNull] IConfigurationExpressionEvaluator evaluator,
     [NotNull] ITokenUsageTracker tokenUsageTracker)
 {
     if (evaluator == null)
     {
         throw new ArgumentNullException(nameof(evaluator));
     }
     if (tokenUsageTracker == null)
     {
         throw new ArgumentNullException(nameof(tokenUsageTracker));
     }
     _evaluator         = evaluator;
     _tokenUsageTracker = tokenUsageTracker;
 }
Ejemplo n.º 3
0
        protected ExpressionEvaluationResults EvaluateCondition(
            [NotNull] XElement element,
            [NotNull] IConfiguration configuration,
            [NotNull] IConfigurationExpressionEvaluator configurationExpressionEvaluator)
        {
            if (element == null)
            {
                throw new ArgumentNullException(nameof(element));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }
            if (configurationExpressionEvaluator == null)
            {
                throw new ArgumentNullException(nameof(configurationExpressionEvaluator));
            }

            string expression         = null;
            var    conditionAttribute = element.Attribute(XName.Get(ConditionAttributeName, string.Empty));

            if (conditionAttribute != null)
            {
                expression = conditionAttribute.Value;
            }

            ExpressionEvaluationResults evaluationResults = configurationExpressionEvaluator.Evaluate(configuration.ConfigurationName, expression, element.Name);

            foreach (var usedToken in evaluationResults.UsedTokens)
            {
                if (configuration.Contains(usedToken))
                {
                    _tokenUsageTracker.OnTokenUsed(configuration.ConfigurationName, usedToken);
                }
                else
                {
                    _tokenUsageTracker.OnTokenNotRecognised(configuration.ConfigurationName, usedToken);
                }
            }

            return(evaluationResults);
        }