Hi all,
I am writing my configuration class. My CustomSection class is derived
from ConfigurationSection. One of my setting is type of TimeSpan. I am
getting a problem to setup the DefaultValue.
The error message I got is " An attribute argument must be a constant
expression, typeof expression or array creation expression."
The problem is TimeSpan.FromMinutes (5) does not return an constant
expression. Anybody has an idea?
public sealed class CustomSection : ConfigurationSection
{
[ConfigurationProperty("maxIdleTime",IsRequired = false,
DefaultValue = TimeSpan.FromMinutes (5))]
[TimeSpanValidator(MinValueString = "0:0:30",
MaxValueString = "5:00:0",
ExcludeRange = false)]
public TimeSpan MaxIdleTime
{
get
{
return (TimeSpan)this["maxIdleTime"];
}
set
{
this["maxIdleTime"] = value;
}
}
}
Thanks in advance,
Davey
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Beer is part of the life.
http://www.lovebeers.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-