Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Q: How are ConfigurationProperty default values assigned toclass/struct attributes?

Reply
 
Old 04-20-2009   #1 (permalink)
Keller


 
 

Q: How are ConfigurationProperty default values assigned toclass/struct attributes?

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:
Quote:
Quote:

>> DefaultValue = "0:10:0",
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:
Quote:
Quote:

>> TimeSpan ts = "0:10:0";
TimeSpan does have Parse() method that takes a string parameter, i.e.
Quote:
Quote:

>> public static TimeSpan Parse(string s);
but I do not see how it is associated in the above sample code.

So again how does this code from the sample work?:
Quote:
Quote:

>> DefaultValue = "0:10:0",
My guess is TimeSpan.Parse() is somehow being called, but where?

TIA,
Keller Beyer
beyeriii@xxxxxx

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
No Assigned Default Gateway, DNS Server or WINS Server... Network & Sharing
How to map openssl obtained private key parameters to RSAParameters struct members? .NET General
How to show non-default attributes PowerShell
Re: How to show non-default attributes PowerShell
Struct\Class Creation PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46