Exemple #1
0
        public bool Add(Trait trait)
        {
            if (trait == null)
            {
                throw new ArgumentException("trait is null");
            }
            if (trait.Definition == null)
            {
                throw new ArgumentException("trait definition is null");
            }
            if (_traits.Any(x => x.Equals(trait)))
            {
                throw new InvalidOperationException("trait named '" + trait.Definition.Name + "' already exists");
            }

            var evaluationManager = new EvaluationManager(trait.Definition, _traits);

            if (!evaluationManager.Evaluate())
            {
                return(false);
            }

            _traits.Add(trait);
            return(true);
        }
Exemple #2
0
 public bool Evaluate(EvaluationManager manager, IReadOnlyCollection <Trait> traits)
 {
     return(_requirements.Aggregate(false, (current, requirement) => current || requirement.Evaluate(manager, traits)));
 }
Exemple #3
0
        public bool Evaluate(EvaluationManager manager, IReadOnlyCollection <Trait> traits)
        {
            var targetTrait = traits.FirstOrDefault(x => x.Definition.Name == Definition.Name);

            return(targetTrait != null && Compare(targetTrait));
        }