Changes approved via private email from Marek Habersack <mhabersack@novell.com> on...
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / OutputCacheProfile.cs
1 //
2 // System.Web.Configuration.OutputCacheProfile
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 using System.Web.UI;
35
36 #if NET_2_0
37
38 namespace System.Web.Configuration {
39
40         public sealed class OutputCacheProfile : ConfigurationElement
41         {
42                 static ConfigurationProperty durationProp;
43                 static ConfigurationProperty enabledProp;
44                 static ConfigurationProperty locationProp;
45                 static ConfigurationProperty nameProp;
46                 static ConfigurationProperty noStoreProp;
47                 static ConfigurationProperty sqlDependencyProp;
48                 static ConfigurationProperty varyByContentEncodingProp;
49                 static ConfigurationProperty varyByControlProp;
50                 static ConfigurationProperty varyByCustomProp;
51                 static ConfigurationProperty varyByHeaderProp;
52                 static ConfigurationProperty varyByParamProp;
53                 static ConfigurationPropertyCollection properties;
54
55                 static OutputCacheProfile ()
56                 {
57                         durationProp = new ConfigurationProperty ("duration", typeof (int), -1);
58                         enabledProp = new ConfigurationProperty ("enabled", typeof (bool), true);
59                         locationProp = new ConfigurationProperty ("location", typeof (OutputCacheLocation), null,
60                                                                   new GenericEnumConverter (typeof (OutputCacheLocation)),
61                                                                   PropertyHelper.DefaultValidator,
62                                                                   ConfigurationPropertyOptions.None);
63                         nameProp = new ConfigurationProperty ("name", typeof (string), "",
64                                                               PropertyHelper.WhiteSpaceTrimStringConverter,
65                                                               PropertyHelper.NonEmptyStringValidator,
66                                                               ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
67                         noStoreProp = new ConfigurationProperty ("noStore", typeof (bool), false);
68                         sqlDependencyProp = new ConfigurationProperty ("sqlDependency", typeof (string));
69                         varyByContentEncodingProp = new ConfigurationProperty ("varyByContentEncoding", typeof (string));
70                         varyByControlProp = new ConfigurationProperty ("varyByControl", typeof (string));
71                         varyByCustomProp = new ConfigurationProperty ("varyByCustom", typeof (string));
72                         varyByHeaderProp = new ConfigurationProperty ("varyByHeader", typeof (string));
73                         varyByParamProp = new ConfigurationProperty ("varyByParam", typeof (string));
74                         properties = new ConfigurationPropertyCollection ();
75
76                         properties.Add (durationProp);
77                         properties.Add (enabledProp);
78                         properties.Add (locationProp);
79                         properties.Add (nameProp);
80                         properties.Add (noStoreProp);
81                         properties.Add (sqlDependencyProp);
82                         properties.Add (varyByContentEncodingProp);
83                         properties.Add (varyByControlProp);
84                         properties.Add (varyByCustomProp);
85                         properties.Add (varyByHeaderProp);
86                         properties.Add (varyByParamProp);
87                 }
88
89                 internal OutputCacheProfile ()
90                 {
91                 }
92
93                 public OutputCacheProfile (string name)
94                 {
95                         this.Name = name;
96                 }
97
98                 [ConfigurationProperty ("duration", DefaultValue = "-1")]
99                 public int Duration {
100                         get { return (int) base [durationProp];}
101                         set { base[durationProp] = value; }
102                 }
103
104                 [ConfigurationProperty ("enabled", DefaultValue = "True")]
105                 public bool Enabled {
106                         get { return (bool) base [enabledProp];}
107                         set { base[enabledProp] = value; }
108                 }
109
110                 [ConfigurationProperty ("location")]
111                 public OutputCacheLocation Location {
112                         get { return (OutputCacheLocation) base [locationProp];}
113                         set { base[locationProp] = value; }
114                 }
115
116                 [StringValidator (MinLength = 1)]
117                 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
118                 [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
119                 public string Name {
120                         get { return (string) base [nameProp];}
121                         set { base[nameProp] = value; }
122                 }
123
124                 [ConfigurationProperty ("noStore", DefaultValue = "False")]
125                 public bool NoStore {
126                         get { return (bool) base [noStoreProp];}
127                         set { base[noStoreProp] = value; }
128                 }
129
130                 [ConfigurationProperty ("sqlDependency")]
131                 public string SqlDependency {
132                         get { return (string) base [sqlDependencyProp];}
133                         set { base[sqlDependencyProp] = value; }
134                 }
135
136                 [ConfigurationPropertyAttribute("varyByContentEncoding")]
137                 public string VaryByContentEncoding {
138                         get { return (string) base [varyByContentEncodingProp]; }
139                         set { base [varyByContentEncodingProp] = value; }
140                 }
141                 
142                 [ConfigurationProperty ("varyByControl")]
143                 public string VaryByControl {
144                         get { return (string) base [varyByControlProp];}
145                         set { base[varyByControlProp] = value; }
146                 }
147
148                 [ConfigurationProperty ("varyByCustom")]
149                 public string VaryByCustom {
150                         get { return (string) base [varyByCustomProp];}
151                         set { base[varyByCustomProp] = value; }
152                 }
153
154                 [ConfigurationProperty ("varyByHeader")]
155                 public string VaryByHeader {
156                         get { return (string) base [varyByHeaderProp];}
157                         set { base[varyByHeaderProp] = value; }
158                 }
159
160                 [ConfigurationProperty ("varyByParam")]
161                 public string VaryByParam {
162                         get { return (string) base [varyByParamProp];}
163                         set { base[varyByParamProp] = value; }
164                 }
165
166                 protected override ConfigurationPropertyCollection Properties {
167                         get { return properties; }
168                 }
169
170         }
171
172 }
173
174 #endif
175