[英]intercept configurationelement set
I want to set a configurationelement property when another property is set. 我想在设置另一个属性时设置configurationelement属性。 I load configuration element with a getsection and the set function is apparently not fired. 我用getsection加载配置元素,而set函数显然没有被触发。
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 谢谢你的帮助
Thanks to all i find a solution, i create an intermediate object from the configelement loaded by getsection. 感谢所有找到的解决方案,我从getsection加载的configelement中创建了一个中间对象。 I can now modify the second property using the set of the other one. 现在,我可以使用另一个属性的集合来修改第二个属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.