OutputCacheProfile.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. //
  2. // System.Web.Configuration.OutputCacheProfile
  3. //
  4. // Authors:
  5. // Chris Toshok ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.ComponentModel;
  31. using System.Configuration;
  32. using System.Web.UI;
  33. #if NET_2_0
  34. namespace System.Web.Configuration {
  35. public sealed class OutputCacheProfile : ConfigurationElement
  36. {
  37. static ConfigurationProperty durationProp;
  38. static ConfigurationProperty enabledProp;
  39. static ConfigurationProperty locationProp;
  40. static ConfigurationProperty nameProp;
  41. static ConfigurationProperty noStoreProp;
  42. static ConfigurationProperty sqlDependencyProp;
  43. static ConfigurationProperty varyByControlProp;
  44. static ConfigurationProperty varyByCustomProp;
  45. static ConfigurationProperty varyByHeaderProp;
  46. static ConfigurationProperty varyByParamProp;
  47. static ConfigurationPropertyCollection properties;
  48. static OutputCacheProfile ()
  49. {
  50. durationProp = new ConfigurationProperty ("duration", typeof (int), -1);
  51. enabledProp = new ConfigurationProperty ("enabled", typeof (bool), true);
  52. locationProp = new ConfigurationProperty ("location", typeof (OutputCacheLocation), null,
  53. new GenericEnumConverter (typeof (OutputCacheLocation)),
  54. PropertyHelper.DefaultValidator,
  55. ConfigurationPropertyOptions.None);
  56. nameProp = new ConfigurationProperty ("name", typeof (string), "",
  57. PropertyHelper.WhiteSpaceTrimStringConverter,
  58. PropertyHelper.NonEmptyStringValidator,
  59. ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
  60. noStoreProp = new ConfigurationProperty ("noStore", typeof (bool), false);
  61. sqlDependencyProp = new ConfigurationProperty ("sqlDependency", typeof (string));
  62. varyByControlProp = new ConfigurationProperty ("varyByControl", typeof (string));
  63. varyByCustomProp = new ConfigurationProperty ("varyByCustom", typeof (string));
  64. varyByHeaderProp = new ConfigurationProperty ("varyByHeader", typeof (string));
  65. varyByParamProp = new ConfigurationProperty ("varyByParam", typeof (string));
  66. properties = new ConfigurationPropertyCollection ();
  67. properties.Add (durationProp);
  68. properties.Add (enabledProp);
  69. properties.Add (locationProp);
  70. properties.Add (nameProp);
  71. properties.Add (noStoreProp);
  72. properties.Add (sqlDependencyProp);
  73. properties.Add (varyByControlProp);
  74. properties.Add (varyByCustomProp);
  75. properties.Add (varyByHeaderProp);
  76. properties.Add (varyByParamProp);
  77. }
  78. internal OutputCacheProfile ()
  79. {
  80. }
  81. public OutputCacheProfile (string name)
  82. {
  83. this.Name = name;
  84. }
  85. [ConfigurationProperty ("duration", DefaultValue = "-1")]
  86. public int Duration {
  87. get { return (int) base [durationProp];}
  88. set { base[durationProp] = value; }
  89. }
  90. [ConfigurationProperty ("enabled", DefaultValue = "True")]
  91. public bool Enabled {
  92. get { return (bool) base [enabledProp];}
  93. set { base[enabledProp] = value; }
  94. }
  95. [ConfigurationProperty ("location")]
  96. public OutputCacheLocation Location {
  97. get { return (OutputCacheLocation) base [locationProp];}
  98. set { base[locationProp] = value; }
  99. }
  100. [StringValidator (MinLength = 1)]
  101. [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
  102. [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
  103. public string Name {
  104. get { return (string) base [nameProp];}
  105. set { base[nameProp] = value; }
  106. }
  107. [ConfigurationProperty ("noStore", DefaultValue = "False")]
  108. public bool NoStore {
  109. get { return (bool) base [noStoreProp];}
  110. set { base[noStoreProp] = value; }
  111. }
  112. [ConfigurationProperty ("sqlDependency")]
  113. public string SqlDependency {
  114. get { return (string) base [sqlDependencyProp];}
  115. set { base[sqlDependencyProp] = value; }
  116. }
  117. [ConfigurationProperty ("varyByControl")]
  118. public string VaryByControl {
  119. get { return (string) base [varyByControlProp];}
  120. set { base[varyByControlProp] = value; }
  121. }
  122. [ConfigurationProperty ("varyByCustom")]
  123. public string VaryByCustom {
  124. get { return (string) base [varyByCustomProp];}
  125. set { base[varyByCustomProp] = value; }
  126. }
  127. [ConfigurationProperty ("varyByHeader")]
  128. public string VaryByHeader {
  129. get { return (string) base [varyByHeaderProp];}
  130. set { base[varyByHeaderProp] = value; }
  131. }
  132. [ConfigurationProperty ("varyByParam")]
  133. public string VaryByParam {
  134. get { return (string) base [varyByParamProp];}
  135. set { base[varyByParamProp] = value; }
  136. }
  137. protected override ConfigurationPropertyCollection Properties {
  138. get { return properties; }
  139. }
  140. }
  141. }
  142. #endif