New test.
[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", typeof (int), 89,
53                                                                                           TypeDescriptor.GetConverter (typeof (int)),
54                                                                                           PropertyHelper.IntFromZeroToMaxValidator,
55                                                                                           ConfigurationPropertyOptions.None);
56                         privateBytesLimitProp = new ConfigurationProperty("privateBytesLimit", typeof (long), 0L,
57                                                                           TypeDescriptor.GetConverter (typeof (long)),
58                                                                           new LongValidator (0, Int64.MaxValue),
59                                                                           ConfigurationPropertyOptions.None);
60                         privateBytesPollTimeProp = new ConfigurationProperty("privateBytesPollTime",
61                                                                              typeof (TimeSpan),
62                                                                              TimeSpan.FromMinutes (2),
63                                                                              PropertyHelper.InfiniteTimeSpanConverter,
64                                                                              PropertyHelper.PositiveTimeSpanValidator,
65                                                                              ConfigurationPropertyOptions.None);
66                         properties = new ConfigurationPropertyCollection();
67
68                         properties.Add (disableExpirationProp);
69                         properties.Add (disableMemoryCollectionProp);
70                         properties.Add (percentagePhysicalMemoryUsedLimitProp);
71                         properties.Add (privateBytesLimitProp);
72                         properties.Add (privateBytesPollTimeProp);
73                 }
74
75                 [ConfigurationProperty ("disableExpiration", DefaultValue = "False")]
76                 public bool DisableExpiration {
77                         get { return (bool) base [disableExpirationProp];}
78                         set { base[disableExpirationProp] = value; }
79                 }
80
81                 [ConfigurationProperty ("disableMemoryCollection", DefaultValue = "False")]
82                 public bool DisableMemoryCollection {
83                         get { return (bool) base [disableMemoryCollectionProp];}
84                         set { base[disableMemoryCollectionProp] = value; }
85                 }
86                         
87                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
88                 [ConfigurationProperty ("percentagePhysicalMemoryUsedLimit", DefaultValue = "89")]
89                 public int PercentagePhysicalMemoryUsedLimit {
90                         get { return (int) base [percentagePhysicalMemoryUsedLimitProp];}
91                         set { base[percentagePhysicalMemoryUsedLimitProp] = value; }
92                 }
93
94                 [LongValidator (MinValue = (long) 0, MaxValue = Int64.MaxValue)]
95                 [ConfigurationProperty ("privateBytesLimit", DefaultValue = "0")]
96                 public long PrivateBytesLimit {
97                         get { return (long) base [privateBytesLimitProp];}
98                         set { base[privateBytesLimitProp] = value; }
99                 }
100
101                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
102                 [ConfigurationProperty ("privateBytesPollTime", DefaultValue = "00:02:00")]
103                 // LAMESPEC: MS lists no validator here but provides one in Properties.
104                 public TimeSpan PrivateBytesPollTime {
105                         get { return (TimeSpan) base [privateBytesPollTimeProp];}
106                         set { base[privateBytesPollTimeProp] = value; }
107                 }
108
109                 protected override ConfigurationPropertyCollection Properties {
110                         get { return properties; }
111                 }
112
113         }
114
115 }
116
117 #endif
118