K
Keller
Hello group,
How are ConfigurationProperty default values (i.e. DefaultValue)
assigned to struct and class attributes (e.g. TimeSpan)?
The Visual Studio 2005 help for
ConfigurationPropertyAttribute.DefaultValue provides the following
sample (I pasted the C# version, but there is also a Visual Basic
version):
/////////////////////////////////////////////////
[ConfigurationProperty("maxIdleTime",
DefaultValue = "0:10:0",
IsRequired = false)]
[TimeSpanValidator(MinValueString = "0:0:30",
MaxValueString = "5:00:0",
ExcludeRange = false)]
public TimeSpan MaxIdleTime
{
get
{
return (TimeSpan)this["maxIdleTime"];
}
set
{
this["maxIdleTime"] = value;
}
}
/////////////////////////////////////////////////
What I am wondering is how does this DefaultValue parameter from the
sample code work:
TimeSpan does not have a constructor or "=" operator that takes a
string parameter, and TimeSpan does not implement IConvertible. For
example, the following does not complile:
TimeSpan does have Parse() method that takes a string parameter, i.e.but I do not see how it is associated in the above sample code.
So again how does this code from the sample work?:
My guess is TimeSpan.Parse() is somehow being called, but where?
TIA,
Keller Beyer
(e-mail address removed)
How are ConfigurationProperty default values (i.e. DefaultValue)
assigned to struct and class attributes (e.g. TimeSpan)?
The Visual Studio 2005 help for
ConfigurationPropertyAttribute.DefaultValue provides the following
sample (I pasted the C# version, but there is also a Visual Basic
version):
/////////////////////////////////////////////////
[ConfigurationProperty("maxIdleTime",
DefaultValue = "0:10:0",
IsRequired = false)]
[TimeSpanValidator(MinValueString = "0:0:30",
MaxValueString = "5:00:0",
ExcludeRange = false)]
public TimeSpan MaxIdleTime
{
get
{
return (TimeSpan)this["maxIdleTime"];
}
set
{
this["maxIdleTime"] = value;
}
}
/////////////////////////////////////////////////
What I am wondering is how does this DefaultValue parameter from the
sample code work:
TimeSpan does not have a constructor or "=" operator that takes a
string parameter, and TimeSpan does not implement IConvertible. For
example, the following does not complile:
TimeSpan does have Parse() method that takes a string parameter, i.e.but I do not see how it is associated in the above sample code.
So again how does this code from the sample work?:
My guess is TimeSpan.Parse() is somehow being called, but where?
TIA,
Keller Beyer
(e-mail address removed)