New tests.
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / OutputCacheSection.cs
1 //
2 // System.Web.Configuration.OutputCacheSection
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005-2010 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.Configuration;
33
34 namespace System.Web.Configuration
35 {
36
37         public sealed class OutputCacheSection : ConfigurationSection
38         {
39                 static ConfigurationProperty enableFragmentCacheProp;
40                 static ConfigurationProperty enableOutputCacheProp;
41                 static ConfigurationProperty omitVaryStarProp;
42                 static ConfigurationProperty sendCacheControlHeaderProp;
43                 static ConfigurationProperty enableKernelCacheForVaryByStarProp;
44 #if NET_4_0
45                 static ConfigurationProperty providersProp;
46                 static ConfigurationProperty defaultProviderNameProp;
47 #endif
48                 
49                 static ConfigurationPropertyCollection properties;
50
51                 static OutputCacheSection ()
52                 {
53                         enableFragmentCacheProp = new ConfigurationProperty ("enableFragmentCache", typeof (bool), true);
54                         enableOutputCacheProp = new ConfigurationProperty ("enableOutputCache", typeof (bool), true);
55                         omitVaryStarProp = new ConfigurationProperty ("omitVaryStar", typeof (bool), false);
56                         sendCacheControlHeaderProp = new ConfigurationProperty ("sendCacheControlHeader", typeof (bool), true);
57                         enableKernelCacheForVaryByStarProp = new ConfigurationProperty ("enableKernelCacheForVaryByStar", typeof (bool), false);
58 #if NET_4_0
59                         providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection));
60                         defaultProviderNameProp = new ConfigurationProperty ("defaultProvider", typeof (string), "AspNetInternalProvider");
61 #endif
62                         
63                         properties = new ConfigurationPropertyCollection ();
64
65                         properties.Add (enableFragmentCacheProp);
66                         properties.Add (enableOutputCacheProp);
67                         properties.Add (omitVaryStarProp);
68                         properties.Add (sendCacheControlHeaderProp);
69                         properties.Add (enableKernelCacheForVaryByStarProp);
70 #if NET_4_0
71                         properties.Add (providersProp);
72                         properties.Add (defaultProviderNameProp);
73 #endif
74                 }
75
76                 [ConfigurationProperty ("enableFragmentCache", DefaultValue = "True")]
77                 public bool EnableFragmentCache {
78                         get { return (bool) base [enableFragmentCacheProp];}
79                         set { base[enableFragmentCacheProp] = value; }
80                 }
81
82                 [ConfigurationProperty ("enableOutputCache", DefaultValue = "True")]
83                 public bool EnableOutputCache {
84                         get { return (bool) base [enableOutputCacheProp];}
85                         set { base[enableOutputCacheProp] = value; }
86                 }
87
88                 [ConfigurationProperty ("enableKernelCacheForVaryByStar", DefaultValue = "False")]
89                 public bool EnableKernelCacheForVaryByStar {
90                         get { return (bool) base [enableKernelCacheForVaryByStarProp]; }
91                         set { base [enableKernelCacheForVaryByStarProp] = value; }
92                 }
93                 
94                 [ConfigurationProperty ("omitVaryStar", DefaultValue = "False")]
95                 public bool OmitVaryStar {
96                         get { return (bool) base [omitVaryStarProp];}
97                         set { base[omitVaryStarProp] = value; }
98                 }
99
100                 [ConfigurationProperty ("sendCacheControlHeader", DefaultValue = "True")]
101                 public bool SendCacheControlHeader {
102                         get { return (bool) base [sendCacheControlHeaderProp];}
103                         set { base[sendCacheControlHeaderProp] = value; }
104                 }
105
106 #if NET_4_0
107                 [StringValidatorAttribute(MinLength = 1)]
108                 [ConfigurationPropertyAttribute("defaultProvider", DefaultValue = "AspNetInternalProvider")]
109                 public string DefaultProviderName {
110                         get { return base [defaultProviderNameProp] as string; }
111                         set { base [defaultProviderNameProp] = value; }
112                 }
113                 
114                 [ConfigurationPropertyAttribute("providers")]
115                 public ProviderSettingsCollection Providers {
116                         get { return base [providersProp] as ProviderSettingsCollection; }
117                 }
118 #endif
119                 
120                 protected override ConfigurationPropertyCollection Properties {
121                         get { return properties; }
122                 }
123
124         }
125
126 }
127
128