public IntegrityResult <EventStream> Resolve(EventStream eventStream, IValidatorResult validatorResult)
        {
            var orderedRevisions = eventStream.Commits.OrderBy(x => x.Revision);
            var result           = new IntegrityResult <EventStream>(new EventStream(orderedRevisions.ToList()), false);

            return(result);
        }
Exemple #2
0
        public IntegrityResult <EventStream> Apply(EventStream eventStream)
        {
            var integrity = new IntegrityResult <EventStream>(eventStream, false);

            var rulesByValidator = rules.GroupBy(x => x.Validator).OrderBy(x => x.Key);

            foreach (var rulesPerValidator in rulesByValidator)
            {
                var validatorResult = rulesPerValidator.Key.Validate(eventStream);
                if (validatorResult.IsValid)
                {
                    continue;
                }

                foreach (var rule in rulesPerValidator.OrderBy(x => x.Resolver.PriorityLevel))
                {
                    integrity = rule.Resolver.Resolve(eventStream, validatorResult);
                    if (integrity.IsIntegrityViolated == false)
                    {
                        break;
                    }
                }
            }

            return(integrity);
        }