S
style
Hello
In my custom configuration section, I'd like to specify an interval
attribute which specifies an interval in milliseconds. I think it would be
very comfortable to get this value directly as a TimeSpan. That's what I
tryied:
[ConfigurationProperty("interval", IsRequired = true)]
public TimeSpan Interval
{
get { return (TimeSpan)this["interval"]; }
set { this["interval"] = value; }
}
I really got a TimeSpan, but unfortunately the value in the attribute is
automatically converted to days. Then I tried this:
[ConfigurationProperty("interval", IsRequired = true)]
public TimeSpan Interval
{
get { return TimeSpan.FromMilliseconds((double)this["interval"]); }
set { this["interval"] = value; }
}
But this did not work at all. Any other ideas how to achieve this?
Kind regards
Thomas
In my custom configuration section, I'd like to specify an interval
attribute which specifies an interval in milliseconds. I think it would be
very comfortable to get this value directly as a TimeSpan. That's what I
tryied:
[ConfigurationProperty("interval", IsRequired = true)]
public TimeSpan Interval
{
get { return (TimeSpan)this["interval"]; }
set { this["interval"] = value; }
}
I really got a TimeSpan, but unfortunately the value in the attribute is
automatically converted to days. Then I tried this:
[ConfigurationProperty("interval", IsRequired = true)]
public TimeSpan Interval
{
get { return TimeSpan.FromMilliseconds((double)this["interval"]); }
set { this["interval"] = value; }
}
But this did not work at all. Any other ideas how to achieve this?
Kind regards
Thomas