Пример #1
0
 protected override string GetMessage(object objectToValidate, string key)
 {
     return(ValidatorUtility.ShowFormattedMessage(
                this.MessageTemplate,
                ValidatorUtility.GetTargetName(currentTarget),
                this.maxLength,
                base.GetMessage(objectToValidate, key)));
 }
Пример #2
0
        protected override void DoValidate(object objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            base.DoValidate(objectToValidate, currentTarget, key, validationResults);
            IArtifactLinkContainer container = objectToValidate as IArtifactLinkContainer;

            if (validationResults.IsValid &&
                ModelCollector.HasValidArtifacts(container) &&
                !ModelCollector.HasRoles(container))
            {
                this.LogValidationResult(validationResults,
                                         ValidatorUtility.ShowFormattedMessage(Resources.ExtenderObjectValidatorMessage, currentTarget),
                                         currentTarget,
                                         key);
            }
        }
Пример #3
0
        protected override void DoValidate(object objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            //TODO: Fix this call if not working
            if (objectToValidate != null)
            {
                //	Ignore objects than have already been validated.
                //
                if (IsValidated(objectToValidate))
                {
                    return;
                }

                Type targetType = objectToValidate.GetType();

                using (FileConfigurationSource configurationSource = new FileConfigurationSource(TargetConfigurationFile))
                {
                    Validator v = ValidationFactory.CreateValidator(targetType, "Common", configurationSource);
                    v.Validate(objectToValidate, validationResults);

                    v = ValidationFactory.CreateValidator(targetType, targetRuleset, configurationSource);
                    v.Validate(objectToValidate, validationResults);
                }
                Debug.WriteLine(String.Format(CultureInfo.CurrentUICulture, "{0} {1}", objectToValidate.ToString(), validationResults.IsValid ? "Succeeded" : "Failed"));
            }
            //base.DoValidate(objectToValidate, currentTarget, key, validationResults);
            IArtifactLinkContainer container = objectToValidate as IArtifactLinkContainer;

            if (validationResults.IsValid &&
                ModelCollector.HasValidArtifacts(container) &&
                !ModelCollector.HasRoles(container))
            {
                this.LogValidationResult(validationResults,
                                         ValidatorUtility.ShowFormattedMessage(Resources.ExtenderObjectValidatorMessage, currentTarget),
                                         currentTarget,
                                         key);
            }
        }