public void ValidationEndsFor(IVisitableDefinition definition)
        {
            ArgumentUtility.CheckNotNull("definition", definition);
            if (_currentData.Count == 0)
            {
                string message = string.Format("Validation of definition {0}/{1} cannot be ended, because it wasn't started.", definition.GetType().Name,
                                               definition.FullName);
                throw new InvalidOperationException(message);
            }
            else
            {
                ValidationResult currentResult = _currentData.Peek();
                // Only compare the full name rather than creating a new ID - it's more performant, and it's only a safety check anyway
                if (currentResult.ValidatedDefinition.FullName != definition.FullName)
                {
                    string message = string.Format(
                        "Cannot end validation for {0} while {1} is validated.",
                        definition.FullName,
                        currentResult.ValidatedDefinition.FullName);
                    throw new InvalidOperationException(message);
                }

                _currentData.Pop();
                _data.Add(currentResult);
            }
        }
        public void ValidationStartsFor(IVisitableDefinition definition)
        {
            ArgumentUtility.CheckNotNull("definition", definition);
            var validationResult = new ValidationResult(definition);

            _currentData.Push(validationResult);
        }
예제 #3
0
        public static void Validate(IVisitableDefinition startingPoint, IValidationLog log, params IRuleSet[] customRuleSets)
        {
            ArgumentUtility.CheckNotNull("startingPoint", startingPoint);
            ArgumentUtility.CheckNotNull("log", log);
            ArgumentUtility.CheckNotNull("customRuleSets", customRuleSets);

            Validate(new[] { startingPoint }, log, customRuleSets);
        }
예제 #4
0
        public static ValidationLogData Validate(IVisitableDefinition startingPoint, params IRuleSet[] customRuleSets)
        {
            ArgumentUtility.CheckNotNull("startingPoint", startingPoint);
            ArgumentUtility.CheckNotNull("customRuleSets", customRuleSets);

            var log = new DefaultValidationLog();

            Validate(startingPoint, log, customRuleSets);
            return(log.GetData());
        }
 private ValidationResult?FindMatchingResult(IVisitableDefinition validatedDefinition)
 {
     foreach (var result in GetResults())
     {
         if (result.ValidatedDefinition == validatedDefinition)
         {
             return(result);
         }
     }
     return(null);
 }
        public ValidationResult(IVisitableDefinition validatedDefinition)
        {
            ArgumentUtility.CheckNotNull("validatedDefinition", validatedDefinition);

            _validatedDefinition = validatedDefinition;

            _successes  = new List <ValidationResultItem> ();
            _warnings   = new List <ValidationResultItem> ();
            _failures   = new List <ValidationResultItem> ();
            _exceptions = new List <ValidationExceptionResultItem> ();
        }
예제 #7
0
        protected MemberDefinitionBase(MemberInfo memberInfo, ClassDefinitionBase declaringClass)
        {
            ArgumentUtility.CheckNotNull("memberInfo", memberInfo);
            ArgumentUtility.CheckNotNull("declaringClass", declaringClass);

            SuppressedReceivedAttributes = new MultiDefinitionCollection <Type, SuppressedAttributeIntroductionDefinition> (a => a.AttributeType);
            ReceivedAttributes           = new MultiDefinitionCollection <Type, AttributeIntroductionDefinition> (a => a.AttributeType);
            CustomAttributes             = new MultiDefinitionCollection <Type, AttributeDefinition> (a => a.AttributeType);

            SuppressedAttributeIntroductions = new MultiDefinitionCollection <Type, SuppressedAttributeIntroductionDefinition> (a => a.AttributeType);
            NonAttributeIntroductions        = new MultiDefinitionCollection <Type, NonAttributeIntroductionDefinition> (a => a.AttributeType);
            AttributeIntroductions           = new MultiDefinitionCollection <Type, AttributeIntroductionDefinition> (a => a.AttributeType);

            MemberInfo     = memberInfo;
            DeclaringClass = declaringClass;
            _parent        = declaringClass;
        }
        private void AssertVisitedEquivalent(IEnumerable <ValidationResult> validationResults, IVisitableDefinition expectedDefinition)
        {
            var match   = validationResults.Any(result => result.ValidatedDefinition.FullName == expectedDefinition.FullName);
            var message = string.Format("Expected {0} '{1}' to be visited.", expectedDefinition.GetType().Name, expectedDefinition.FullName);

            Assert.That(match, message);
        }