intercept configurationelement set

339 views Asked by At

I want to set a configurationelement property when another property is set. I load configuration element with a getsection and the set function is apparently not fired.

code:

    [ConfigurationProperty("type", DefaultValue = "String", IsRequired = true)]
    public DbType type
    {
        get
        {
            return (DbType)this["type"];
        }
        set
        {
            this["type"] = value;
            //^-?\d*[0-9]?(|.\d*[0-9]|,\d*[0-9])?$ décimal
            //^-?\d*[0-9]
            tabloidConfigValideur tcv = new tabloidConfigValideur();
            tcv.nom = "autoValideur" + this.valideurs.Count;
            tcv.type = tabloidConfig.validationType.regExp;
            switch(value)
            {
                case DbType.Boolean:
                    this["editeur"] = TemplateType.checkBox;
                    break;
                case DbType.Int16:
                case DbType.Int32:
                case DbType.Int64:
                    tcv.param = @"^-?\d*[0-9]";
                    tcv.message = " doit être un entier";
                    break;
                case DbType.UInt16:
                case DbType.UInt32:
                case DbType.UInt64:
                    tcv.param = @"\d*[0-9]";
                    tcv.message = "doit être un entier sans signe";
                    break;
            }

            if (WebConfigurationManager.AppSettings["valideurAuto"].ToLower()=="oui"&&string.IsNullOrEmpty(tcv.param)) this.valideurs.Add(tcv);
        }
    }

thanks for your help

1

There are 1 answers

0
JD11 On BEST ANSWER

Thanks to all i find a solution, i create an intermediate object from the configelement loaded by getsection. I can now modify the second property using the set of the other one.