location,location,location. Fixes all the tests I broke last night
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / CacheSection.cs
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 //
9
10 //
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.
29 //
30
31 using System;
32 using System.ComponentModel;
33 using System.Configuration;
34
35 #if NET_2_0
36
37 namespace System.Web.Configuration {
38
39         public sealed class CacheSection : ConfigurationSection
40         {
41                 static ConfigurationProperty disableExpirationProp;
42                 static ConfigurationProperty disableMemoryCollectionProp;
43                 static ConfigurationProperty percentagePhysicalMemoryUsedLimitProp;
44                 static ConfigurationProperty privateBytesLimitProp;
45                 static ConfigurationProperty privateBytesPollTimeProp;
46                 static ConfigurationPropertyCollection properties;
47
48                 static CacheSection ()
49                 {
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();
68
69                         properties.Add (disableExpirationProp);
70                         properties.Add (disableMemoryCollectionProp);
71                         properties.Add (percentagePhysicalMemoryUsedLimitProp);
72                         properties.Add (privateBytesLimitProp);
73                         properties.Add (privateBytesPollTimeProp);
74                 }
75
76                 [ConfigurationProperty ("disableExpiration", DefaultValue = "False")]
77                 public bool DisableExpiration {
78                         get { return (bool) base [disableExpirationProp];}
79                         set { base[disableExpirationProp] = value; }
80                 }
81
82                 [ConfigurationProperty ("disableMemoryCollection", DefaultValue = "False")]
83                 public bool DisableMemoryCollection {
84                         get { return (bool) base [disableMemoryCollectionProp];}
85                         set { base[disableMemoryCollectionProp] = value; }
86                 }
87                         
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; }
93                 }
94
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; }
100                 }
101
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; }
108                 }
109
110                 protected override ConfigurationPropertyCollection Properties {
111                         get { return properties; }
112                 }
113
114         }
115
116 }
117
118 #endif
119