OutputCacheProfile.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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));
  53. nameProp = new ConfigurationProperty ("name", typeof (string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
  54. noStoreProp = new ConfigurationProperty ("noStore", typeof (bool), false);
  55. sqlDependencyProp = new ConfigurationProperty ("sqlDependency", typeof (string));
  56. varyByControlProp = new ConfigurationProperty ("varyByControl", typeof (string));
  57. varyByCustomProp = new ConfigurationProperty ("varyByCustom", typeof (string));
  58. varyByHeaderProp = new ConfigurationProperty ("varyByHeader", typeof (string));
  59. varyByParamProp = new ConfigurationProperty ("varyByParam", typeof (string));
  60. properties = new ConfigurationPropertyCollection ();
  61. properties.Add (durationProp);
  62. properties.Add (enabledProp);
  63. properties.Add (locationProp);
  64. properties.Add (nameProp);
  65. properties.Add (noStoreProp);
  66. properties.Add (sqlDependencyProp);
  67. properties.Add (varyByControlProp);
  68. properties.Add (varyByCustomProp);
  69. properties.Add (varyByHeaderProp);
  70. properties.Add (varyByParamProp);
  71. }
  72. public OutputCacheProfile (string name)
  73. {
  74. this.Name = name;
  75. }
  76. [ConfigurationProperty ("duration", DefaultValue = "-1")]
  77. public int Duration {
  78. get { return (int) base [durationProp];}
  79. set { base[durationProp] = value; }
  80. }
  81. [ConfigurationProperty ("enabled", DefaultValue = "True")]
  82. public bool Enabled {
  83. get { return (bool) base [enabledProp];}
  84. set { base[enabledProp] = value; }
  85. }
  86. [ConfigurationProperty ("location")]
  87. public OutputCacheLocation Location {
  88. get { return (OutputCacheLocation) base [locationProp];}
  89. set { base[locationProp] = value; }
  90. }
  91. [StringValidator (MinLength = 1)]
  92. [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
  93. [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
  94. public string Name {
  95. get { return (string) base [nameProp];}
  96. set { base[nameProp] = value; }
  97. }
  98. [ConfigurationProperty ("noStore", DefaultValue = "False")]
  99. public bool NoStore {
  100. get { return (bool) base [noStoreProp];}
  101. set { base[noStoreProp] = value; }
  102. }
  103. [ConfigurationProperty ("sqlDependency")]
  104. public string SqlDependency {
  105. get { return (string) base [sqlDependencyProp];}
  106. set { base[sqlDependencyProp] = value; }
  107. }
  108. [ConfigurationProperty ("varyByControl")]
  109. public string VaryByControl {
  110. get { return (string) base [varyByControlProp];}
  111. set { base[varyByControlProp] = value; }
  112. }
  113. [ConfigurationProperty ("varyByCustom")]
  114. public string VaryByCustom {
  115. get { return (string) base [varyByCustomProp];}
  116. set { base[varyByCustomProp] = value; }
  117. }
  118. [ConfigurationProperty ("varyByHeader")]
  119. public string VaryByHeader {
  120. get { return (string) base [varyByHeaderProp];}
  121. set { base[varyByHeaderProp] = value; }
  122. }
  123. [ConfigurationProperty ("varyByParam")]
  124. public string VaryByParam {
  125. get { return (string) base [varyByParamProp];}
  126. set { base[varyByParamProp] = value; }
  127. }
  128. protected override ConfigurationPropertyCollection Properties {
  129. get { return properties; }
  130. }
  131. }
  132. }
  133. #endif