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 varyByControlProp;
49 static ConfigurationProperty varyByCustomProp;
50 static ConfigurationProperty varyByHeaderProp;
51 static ConfigurationProperty varyByParamProp;
52 static ConfigurationPropertyCollection properties;
54 static OutputCacheProfile ()
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 ();
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);
86 internal OutputCacheProfile ()
90 public OutputCacheProfile (string name)
95 [ConfigurationProperty ("duration", DefaultValue = "-1")]
97 get { return (int) base [durationProp];}
98 set { base[durationProp] = value; }
101 [ConfigurationProperty ("enabled", DefaultValue = "True")]
102 public bool Enabled {
103 get { return (bool) base [enabledProp];}
104 set { base[enabledProp] = value; }
107 [ConfigurationProperty ("location")]
108 public OutputCacheLocation Location {
109 get { return (OutputCacheLocation) base [locationProp];}
110 set { base[locationProp] = value; }
113 [StringValidator (MinLength = 1)]
114 [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
115 [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
117 get { return (string) base [nameProp];}
118 set { base[nameProp] = value; }
121 [ConfigurationProperty ("noStore", DefaultValue = "False")]
122 public bool NoStore {
123 get { return (bool) base [noStoreProp];}
124 set { base[noStoreProp] = value; }
127 [ConfigurationProperty ("sqlDependency")]
128 public string SqlDependency {
129 get { return (string) base [sqlDependencyProp];}
130 set { base[sqlDependencyProp] = value; }
133 [ConfigurationProperty ("varyByControl")]
134 public string VaryByControl {
135 get { return (string) base [varyByControlProp];}
136 set { base[varyByControlProp] = value; }
139 [ConfigurationProperty ("varyByCustom")]
140 public string VaryByCustom {
141 get { return (string) base [varyByCustomProp];}
142 set { base[varyByCustomProp] = value; }
145 [ConfigurationProperty ("varyByHeader")]
146 public string VaryByHeader {
147 get { return (string) base [varyByHeaderProp];}
148 set { base[varyByHeaderProp] = value; }
151 [ConfigurationProperty ("varyByParam")]
152 public string VaryByParam {
153 get { return (string) base [varyByParamProp];}
154 set { base[varyByParamProp] = value; }
157 protected override ConfigurationPropertyCollection Properties {
158 get { return properties; }