public override void VerifyRule(IRuleRequest request = null)
        {
            base.VerifyRule(request);
            if (!StorageMechanism.Items.Any())
            {
                Logger("INFO", $"Cache empty for {RuleSetName}");
                return;
            }
            if (AggregateRule == null)
            {
                Logger("ERROR", $"Aggregate rule for {RuleSetName} is empty");
                return;
            }

            var filtered = AggregateFilter != null
                ? AggregateFilter.Compile().Invoke(StorageMechanism.Items, RuleRequest)
                : StorageMechanism.Items;

            var invalid = AggregateRule.Compile().Invoke(filtered);

            if (!invalid)
            {
                return;
            }
            FailRule();
        }
Esempio n. 2
0
        private void VerifyAggregateRule()
        {
            if (AggregateRule == null)
            {
                return;
            }
            IEnumerable <T> filtered;

            if (AggregateFilter != null)
            {
                filtered = AggregateFilter.Compile().Invoke(StorageMechanism().Cast <T>(), _ruleRequest);
            }
            else
            {
                filtered = StorageMechanism().Cast <T>();
            }

            var invalid = AggregateRule.Compile().Invoke(filtered);

            if (invalid)
            {
                _logger("WARN", "Rule Failed VerifyAggregateRule");
                InvalidAction();
            }
        }