Backport of some changes from svn trunk - performance improvement and a fix for bug...
[mono-project.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / CacheSection.cs
blob5e6078f1bb255c39369a2e9d9489990f2712200a
1 //
2 // System.Web.Configuration.CacheSection
3 //
4 // Authors:
5 // Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.ComponentModel;
33 using System.Configuration;
35 #if NET_2_0
37 namespace System.Web.Configuration {
39 public sealed class CacheSection : ConfigurationSection
41 static ConfigurationProperty disableExpirationProp;
42 static ConfigurationProperty disableMemoryCollectionProp;
43 static ConfigurationProperty percentagePhysicalMemoryUsedLimitProp;
44 static ConfigurationProperty privateBytesLimitProp;
45 static ConfigurationProperty privateBytesPollTimeProp;
46 static ConfigurationPropertyCollection properties;
48 static CacheSection ()
50 disableExpirationProp = new ConfigurationProperty("disableExpiration", typeof (bool), false);
51 disableMemoryCollectionProp = new ConfigurationProperty("disableMemoryCollection", typeof (bool), false);
52 percentagePhysicalMemoryUsedLimitProp = new ConfigurationProperty("percentagePhysicalMemoryUsedLimit",
53 typeof (int), 0,
54 TypeDescriptor.GetConverter (typeof (int)),
55 PropertyHelper.IntFromZeroToMaxValidator,
56 ConfigurationPropertyOptions.None);
57 privateBytesLimitProp = new ConfigurationProperty("privateBytesLimit", typeof (long), 0L,
58 TypeDescriptor.GetConverter (typeof (long)),
59 new LongValidator (0, Int64.MaxValue),
60 ConfigurationPropertyOptions.None);
61 privateBytesPollTimeProp = new ConfigurationProperty("privateBytesPollTime",
62 typeof (TimeSpan),
63 TimeSpan.FromMinutes (2),
64 PropertyHelper.InfiniteTimeSpanConverter,
65 PropertyHelper.PositiveTimeSpanValidator,
66 ConfigurationPropertyOptions.None);
67 properties = new ConfigurationPropertyCollection();
69 properties.Add (disableExpirationProp);
70 properties.Add (disableMemoryCollectionProp);
71 properties.Add (percentagePhysicalMemoryUsedLimitProp);
72 properties.Add (privateBytesLimitProp);
73 properties.Add (privateBytesPollTimeProp);
76 [ConfigurationProperty ("disableExpiration", DefaultValue = "False")]
77 public bool DisableExpiration {
78 get { return (bool) base [disableExpirationProp];}
79 set { base[disableExpirationProp] = value; }
82 [ConfigurationProperty ("disableMemoryCollection", DefaultValue = "False")]
83 public bool DisableMemoryCollection {
84 get { return (bool) base [disableMemoryCollectionProp];}
85 set { base[disableMemoryCollectionProp] = value; }
88 [IntegerValidator (MinValue = 0, MaxValue = 100)]
89 [ConfigurationProperty ("percentagePhysicalMemoryUsedLimit", DefaultValue = "0")]
90 public int PercentagePhysicalMemoryUsedLimit {
91 get { return (int) base [percentagePhysicalMemoryUsedLimitProp];}
92 set { base[percentagePhysicalMemoryUsedLimitProp] = value; }
95 [LongValidator (MinValue = (long) 0, MaxValue = Int64.MaxValue)]
96 [ConfigurationProperty ("privateBytesLimit", DefaultValue = "0")]
97 public long PrivateBytesLimit {
98 get { return (long) base [privateBytesLimitProp];}
99 set { base[privateBytesLimitProp] = value; }
102 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
103 [ConfigurationProperty ("privateBytesPollTime", DefaultValue = "00:02:00")]
104 // LAMESPEC: MS lists no validator here but provides one in Properties.
105 public TimeSpan PrivateBytesPollTime {
106 get { return (TimeSpan) base [privateBytesPollTimeProp];}
107 set { base[privateBytesPollTimeProp] = value; }
110 protected override ConfigurationPropertyCollection Properties {
111 get { return properties; }
118 #endif