2006-06-08 Chris Toshok <toshok@ximian.com>
[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 varyByControlProp;
49                 static ConfigurationProperty varyByCustomProp;
50                 static ConfigurationProperty varyByHeaderProp;
51                 static ConfigurationProperty varyByParamProp;
52                 static ConfigurationPropertyCollection properties;
53
54                 static OutputCacheProfile ()
55                 {
56                         durationProp = new ConfigurationProperty ("duration", typeof (int), -1);
57                         enabledProp = new ConfigurationProperty ("enabled", typeof (bool), true);
58                         locationProp = new ConfigurationProperty ("location", typeof (OutputCacheLocation), null,
59                                                                   new GenericEnumConverter (typeof (OutputCacheLocation)),
60                                                                   PropertyHelper.DefaultValidator,
61                                                                   ConfigurationPropertyOptions.None);
62                         nameProp = new ConfigurationProperty ("name", typeof (string), "",
63                                                               PropertyHelper.WhiteSpaceTrimStringConverter,
64                                                               PropertyHelper.NonEmptyStringValidator,
65                                                               ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
66                         noStoreProp = new ConfigurationProperty ("noStore", typeof (bool), false);
67                         sqlDependencyProp = new ConfigurationProperty ("sqlDependency", typeof (string));
68                         varyByControlProp = new ConfigurationProperty ("varyByControl", typeof (string));
69                         varyByCustomProp = new ConfigurationProperty ("varyByCustom", typeof (string));
70                         varyByHeaderProp = new ConfigurationProperty ("varyByHeader", typeof (string));
71                         varyByParamProp = new ConfigurationProperty ("varyByParam", typeof (string));
72                         properties = new ConfigurationPropertyCollection ();
73
74                         properties.Add (durationProp);
75                         properties.Add (enabledProp);
76                         properties.Add (locationProp);
77                         properties.Add (nameProp);
78                         properties.Add (noStoreProp);
79                         properties.Add (sqlDependencyProp);
80                         properties.Add (varyByControlProp);
81                         properties.Add (varyByCustomProp);
82                         properties.Add (varyByHeaderProp);
83                         properties.Add (varyByParamProp);
84                 }
85
86                 internal OutputCacheProfile ()
87                 {
88                 }
89
90                 public OutputCacheProfile (string name)
91                 {
92                         this.Name = name;
93                 }
94
95                 [ConfigurationProperty ("duration", DefaultValue = "-1")]
96                 public int Duration {
97                         get { return (int) base [durationProp];}
98                         set { base[durationProp] = value; }
99                 }
100
101                 [ConfigurationProperty ("enabled", DefaultValue = "True")]
102                 public bool Enabled {
103                         get { return (bool) base [enabledProp];}
104                         set { base[enabledProp] = value; }
105                 }
106
107                 [ConfigurationProperty ("location")]
108                 public OutputCacheLocation Location {
109                         get { return (OutputCacheLocation) base [locationProp];}
110                         set { base[locationProp] = value; }
111                 }
112
113                 [StringValidator (MinLength = 1)]
114                 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
115                 [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
116                 public string Name {
117                         get { return (string) base [nameProp];}
118                         set { base[nameProp] = value; }
119                 }
120
121                 [ConfigurationProperty ("noStore", DefaultValue = "False")]
122                 public bool NoStore {
123                         get { return (bool) base [noStoreProp];}
124                         set { base[noStoreProp] = value; }
125                 }
126
127                 [ConfigurationProperty ("sqlDependency")]
128                 public string SqlDependency {
129                         get { return (string) base [sqlDependencyProp];}
130                         set { base[sqlDependencyProp] = value; }
131                 }
132
133                 [ConfigurationProperty ("varyByControl")]
134                 public string VaryByControl {
135                         get { return (string) base [varyByControlProp];}
136                         set { base[varyByControlProp] = value; }
137                 }
138
139                 [ConfigurationProperty ("varyByCustom")]
140                 public string VaryByCustom {
141                         get { return (string) base [varyByCustomProp];}
142                         set { base[varyByCustomProp] = value; }
143                 }
144
145                 [ConfigurationProperty ("varyByHeader")]
146                 public string VaryByHeader {
147                         get { return (string) base [varyByHeaderProp];}
148                         set { base[varyByHeaderProp] = value; }
149                 }
150
151                 [ConfigurationProperty ("varyByParam")]
152                 public string VaryByParam {
153                         get { return (string) base [varyByParamProp];}
154                         set { base[varyByParamProp] = value; }
155                 }
156
157                 protected override ConfigurationPropertyCollection Properties {
158                         get { return properties; }
159                 }
160
161         }
162
163 }
164
165 #endif
166