2 // System.Web.Configuration.OutputCacheProfile
5 // Chris Toshok (toshok@ximian.com)
7 // (C) 2005 Novell, Inc (http://www.novell.com)
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
32 using System.ComponentModel;
33 using System.Configuration;
38 namespace System.Web.Configuration {
40 public sealed class OutputCacheProfile : ConfigurationElement
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;
55 static OutputCacheProfile ()
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 ();
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);
89 internal OutputCacheProfile ()
93 public OutputCacheProfile (string name)
98 [ConfigurationProperty ("duration", DefaultValue = "-1")]
100 get { return (int) base [durationProp];}
101 set { base[durationProp] = value; }
104 [ConfigurationProperty ("enabled", DefaultValue = "True")]
105 public bool Enabled {
106 get { return (bool) base [enabledProp];}
107 set { base[enabledProp] = value; }
110 [ConfigurationProperty ("location")]
111 public OutputCacheLocation Location {
112 get { return (OutputCacheLocation) base [locationProp];}
113 set { base[locationProp] = value; }
116 [StringValidator (MinLength = 1)]
117 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
118 [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
120 get { return (string) base [nameProp];}
121 set { base[nameProp] = value; }
124 [ConfigurationProperty ("noStore", DefaultValue = "False")]
125 public bool NoStore {
126 get { return (bool) base [noStoreProp];}
127 set { base[noStoreProp] = value; }
130 [ConfigurationProperty ("sqlDependency")]
131 public string SqlDependency {
132 get { return (string) base [sqlDependencyProp];}
133 set { base[sqlDependencyProp] = value; }
136 [ConfigurationPropertyAttribute("varyByContentEncoding")]
137 public string VaryByContentEncoding {
138 get { return (string) base [varyByContentEncodingProp]; }
139 set { base [varyByContentEncodingProp] = value; }
142 [ConfigurationProperty ("varyByControl")]
143 public string VaryByControl {
144 get { return (string) base [varyByControlProp];}
145 set { base[varyByControlProp] = value; }
148 [ConfigurationProperty ("varyByCustom")]
149 public string VaryByCustom {
150 get { return (string) base [varyByCustomProp];}
151 set { base[varyByCustomProp] = value; }
154 [ConfigurationProperty ("varyByHeader")]
155 public string VaryByHeader {
156 get { return (string) base [varyByHeaderProp];}
157 set { base[varyByHeaderProp] = value; }
160 [ConfigurationProperty ("varyByParam")]
161 public string VaryByParam {
162 get { return (string) base [varyByParamProp];}
163 set { base[varyByParamProp] = value; }
166 protected override ConfigurationPropertyCollection Properties {
167 get { return properties; }