/// <summary>Initializes a new instance of the <see cref="T:System.Configuration.ConfigurationElementProperty" /> class, based on a supplied parameter.</summary>
 /// <param name="validator">A <see cref="T:System.Configuration.ConfigurationValidatorBase" /> object.</param>
 /// <exception cref="T:System.ArgumentNullException">
 /// <paramref name="validator" /> is <see langword="null" />.</exception>
 public ConfigurationElementProperty(ConfigurationValidatorBase validator)
 {
     if (validator == null)
     {
         throw new ArgumentNullException(nameof(validator));
     }
     this._validator = validator;
 }
Exemplo n.º 2
0
 protected internal static ConfigurationProperty Register(
     string name,
     Type type,
     Type declaringType,
     object defaultValue,
     TypeConverter typeConverter,
     ConfigurationValidatorBase validator,
     ConfigurationPropertyOptions options) =>
 ConfigurationElement.Register(declaringType,
                               new ConfigurationProperty(name, type, defaultValue, typeConverter, validator, options, null));
Exemplo n.º 3
0
 protected internal static ConfigurationProperty Register(
     string name,
     Type type,
     Type declaringType,
     object defaultValue,
     TypeConverter typeConverter,
     ConfigurationValidatorBase validator,
     ConfigurationPropertyOptions options,
     string description)
 {
     return(Register(declaringType,
                     new ConfigurationProperty(name, type, defaultValue, typeConverter, validator, options, description)));
 }
Exemplo n.º 4
0
 private void ValidateConfigValue(ConfigurationProperty property, object value)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     ExchangeConfigurationSection.RunConfigOperation(delegate
     {
         ConfigurationValidatorBase validator = property.Validator;
         if (validator != null)
         {
             validator.Validate(value);
         }
     }, (Exception ex) => new ConfigurationSettingsPropertyFailedValidationException(property.Name, (value != null) ? value.ToString() : null, ex));
 }
Exemplo n.º 5
0
        // </Snippet87>

        // <Snippet88>
        static public void GetElementValidator()
        {
            // Get the current configuration file.
            System.Configuration.Configuration config =
                ConfigurationManager.OpenExeConfiguration(
                    ConfigurationUserLevel.None);

            // Get the section.
            UrlsSection section =
                (UrlsSection)config.GetSection("MyUrls");

            // Get the element.
            UrlConfigElement url = section.Simple;

            // Get the element source file.
            ConfigurationValidatorBase elValidator =
                url.ElementInformation.Validator;

            Console.WriteLine("Url element validator: {0}",
                              elValidator.ToString());
        }
 public override void Validate(object value, bool silent)
 {
     if (ValidatorInstance is ChoValidatorBase)
     {
         ChoValidatorBase validatorInstance = ValidatorInstance as ChoValidatorBase;
         if (validatorInstance != null &&
             !silent &&
             (value != null && validatorInstance.CanValidate(value.GetType())))
         {
             validatorInstance.Validate(value);
         }
     }
     else if (ValidatorInstance is ConfigurationValidatorBase)
     {
         ConfigurationValidatorBase validatorInstance = ValidatorInstance as ConfigurationValidatorBase;
         if (validatorInstance != null &&
             !silent &&
             (value != null && validatorInstance.CanValidate(value.GetType())))
         {
             validatorInstance.Validate(value);
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes the <see cref="RouteElement"/> class.
        /// </summary>
        static RouteElement()
        {
            _nonEmptyStringValidator = new StringValidator(1);

            _propName = new ConfigurationProperty(
                "name", typeof(string), null, null, _nonEmptyStringValidator,
                ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired);

            _propUrl = new ConfigurationProperty(
                "url", typeof(string), null, null,
                _nonEmptyStringValidator,
                ConfigurationPropertyOptions.IsRequired);

            _propHandlerType = new ConfigurationProperty(
                "routeHandlerType", typeof(string),
                string.Empty, ConfigurationPropertyOptions.None);

            _propDefaults = new ConfigurationProperty(
                "defaults", typeof(RouteAttributeElement),
                null, ConfigurationPropertyOptions.None);

            _propConstraints = new ConfigurationProperty(
                "constraints", typeof(RouteAttributeElement),
                null, ConfigurationPropertyOptions.None);

            _propDataTokens = new ConfigurationProperty(
                "dataTokens", typeof(RouteAttributeElement),
                null, ConfigurationPropertyOptions.None);

            _properties = new ConfigurationPropertyCollection();
            _properties.Add(_propName);
            _properties.Add(_propUrl);
            _properties.Add(_propHandlerType);
            _properties.Add(_propDefaults);
            _properties.Add(_propConstraints);
            _properties.Add(_propDataTokens);
        }
 public ConfigurationValidatorWrappingValidator(ConfigurationValidatorBase validatorInstance)
 {
     this.validatorInstance = validatorInstance;
 }
Exemplo n.º 9
0
 public ConfigurationValidatorBaseRule(ConfigurationValidatorBase validator)
 {
     this.ConfigurationValidator = validator;
 }
Exemplo n.º 10
0
 public ConfigurationValidatorWrappingValidator(ConfigurationValidatorBase validatorInstance, object convertedValue)
 {
     this.validatorInstance = validatorInstance;
     this.convertedValue    = convertedValue;
 }
 public ConfigurationProperty(string name, Type type, object defaultValue, System.ComponentModel.TypeConverter typeConverter, ConfigurationValidatorBase validator, ConfigurationPropertyOptions options)
 {
 }
 public ConfigurationElementProperty(ConfigurationValidatorBase validator !!)
 {
 public ChoConfigurationValidatorBaseSurrogateValidator(ConfigurationValidatorBase validator)
 {
     ChoGuard.ArgumentNotNull(validator, "Validator");
     _validator = validator;
 }
Exemplo n.º 14
0
 protected internal virtual ConfigurationProperty CreateNameConfigurationProperty(object defaultValue, ConfigurationPropertyOptions options, ConfigurationValidatorBase validator)
 {
     return(new ConfigurationProperty(this.NamePropertyName, typeof(string), defaultValue, null, validator, options));
 }
 public ChoConfigurationValidatorAttributeSurrogateValidator(ConfigurationValidatorAttribute validationAttribute)
 {
     ChoGuard.ArgumentNotNull(validationAttribute, "ValidationAttribute");
     _configurationValidatorBase = validationAttribute.ValidatorInstance;
 }
 public ConfigurationElementProperty(ConfigurationValidatorBase validator)
 {
     this.validator = validator;
 }
	public ConfigurationProperty(string name, Type type, object defaultValue, System.ComponentModel.TypeConverter typeConverter, ConfigurationValidatorBase validator, ConfigurationPropertyOptions options, string description) {}
		public ConfigurationElementProperty (ConfigurationValidatorBase validator)
		{
			this.validator = validator;
		}