using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using System.Collections.Specialized;
using System.Net.Mail;
using System.Text.RegularExpressions;

namespace TERASOLUNA.Fw.CommonUT.Validation.VabValidatorTestData
{
    [ConfigurationElementType(typeof(CustomValidatorData))]
    class DummyValidator06_With1ErrorAnd3NestedError : Validator
    {
        public DummyValidator06_With1ErrorAnd3NestedError(NameValueCollection attributes)
            : base(null, null)
        {
        }

        protected DummyValidator06_With1ErrorAnd3NestedError(string messageTemplate, string tag)
            : base(messageTemplate, tag)
        {
        }

        protected override string DefaultMessageTemplate
        {
            get { return "DummyValidator05_With1ErrorAnd3NestedError_fail"; }
        }

        protected override void DoValidate(object objectToValidate,
                                          object currentTarget,
                                           string key,
                                           ValidationResults validationResults)
        {
            //ネストされた結果3つ
            ValidationResult nestedResult1 =
                new ValidationResult("NestedResult01", currentTarget, key, Tag, this);

            ValidationResult nestedResult2 =
                new ValidationResult("NestedResult02", currentTarget, key, Tag, this);

            ValidationResult nestedResult3 =
                new ValidationResult("NestedResult03", currentTarget, key, Tag, this);

            List<ValidationResult> nestedResults = new List<ValidationResult>();

            nestedResults.Add(nestedResult1);
            nestedResults.Add(nestedResult2);
            nestedResults.Add(nestedResult3);
            // 結果2つをネストして結果を生成。
            ValidationResult result = 
                new ValidationResult(GetMessage(objectToValidate, key),currentTarget,key,Tag,this,nestedResults);

            validationResults.AddResult(result);
            return;
        }
    }
}
