using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Microsoft.Practices.RecipeFramework.Extensions.Validators
{
    /// <summary/>
    public class TypeNameValidatorAttribute : ConfigurationValidatorAttribute
    {
        private bool multipleTypes;
        private bool optional;

        /// <summary>
        /// Initializes a new instance of the <see cref="T:TypeNameValidatorAttribute"/> class.
        /// </summary>
        public TypeNameValidatorAttribute()
        {
        }

        /// <summary>
        /// Gets the validator attribute instance.
        /// </summary>
        /// <value></value>
        /// <returns>The current <see cref="T:System.Configuration.ConfigurationValidatorBase"></see>.</returns>
        public override ConfigurationValidatorBase ValidatorInstance
        {
            get
            {
                TypeNameValidator validator = new TypeNameValidator();
                validator.MultipleTypes = multipleTypes;
                validator.Optional = optional;
                return validator;
            }
        }

        /// <summary>
        /// Especifies if the value can contain more than one type separated with ","
        /// </summary>
        public bool MultipleTypes
        {
            get { return multipleTypes; }
            set { multipleTypes = value; }
        }

        /// <summary>
        /// Especifies if the value is optional
        /// </summary>
        public bool Optional
        {
            get { return optional; }
            set { optional = value; }
        }
    }
}
