1

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

gregwhitaker
  • 13,124
  • 7
  • 69
  • 78
JD11
  • 306
  • 3
  • 11
  • What language is this? And what exactly is your question? – Sid Holland Jan 13 '13 at 21:09
  • Hi,this c# code. I need to intercept write event on a property to set an other property. But when i use getsection to load properties set part are not executed. – JD11 Jan 15 '13 at 11:34

1 Answers1

0

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.

JD11
  • 306
  • 3
  • 11