PC Review


Reply
Thread Tools Rate Thread

Default value in CongurationSection class property

 
 
Davey
Guest
Posts: n/a
 
      8th Jan 2007
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Property value of class instance by passing string property name mrussell@bluebayinvest.com Microsoft Excel Programming 2 19th Oct 2007 05:47 PM
Base class property Attribute not applied to derived class propert =?Utf-8?B?RGF2aWQgTA==?= Microsoft Dot NET Framework 0 9th Mar 2005 08:53 PM
Re: class property default value gerry Microsoft Dot NET Framework 1 4th Jan 2005 01:20 PM
REPOST:Hiding base class property from derived class instance Baski Microsoft C# .NET 7 14th Dec 2004 10:04 PM
Class 'System.Data.SqlClient.SqlDataAdapter' cannot be indexed because it has no default property. Bob of the West Microsoft ASP .NET 1 17th May 2004 04:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 AM.