OutputCacheProfile.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. public OutputCacheProfile (string name)
  79. {
  80. this.Name = name;
  81. }
  82. [ConfigurationProperty ("duration", DefaultValue = "-1")]
  83. public int Duration {
  84. get { return (int) base [durationProp];}
  85. set { base[durationProp] = value; }
  86. }
  87. [ConfigurationProperty ("enabled", DefaultValue = "True")]
  88. public bool Enabled {
  89. get { return (bool) base [enabledProp];}
  90. set { base[enabledProp] = value; }
  91. }
  92. [ConfigurationProperty ("location")]
  93. public OutputCacheLocation Location {
  94. get { return (OutputCacheLocation) base [locationProp];}
  95. set { base[locationProp] = value; }
  96. }
  97. [StringValidator (MinLength = 1)]
  98. [TypeConverter (typeof (WhiteSpaceTrimStringConverter))]
  99. [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
  100. public string Name {
  101. get { return (string) base [nameProp];}
  102. set { base[nameProp] = value; }
  103. }
  104. [ConfigurationProperty ("noStore", DefaultValue = "False")]
  105. public bool NoStore {
  106. get { return (bool) base [noStoreProp];}
  107. set { base[noStoreProp] = value; }
  108. }
  109. [ConfigurationProperty ("sqlDependency")]
  110. public string SqlDependency {
  111. get { return (string) base [sqlDependencyProp];}
  112. set { base[sqlDependencyProp] = value; }
  113. }
  114. [ConfigurationProperty ("varyByControl")]
  115. public string VaryByControl {
  116. get { return (string) base [varyByControlProp];}
  117. set { base[varyByControlProp] = value; }
  118. }
  119. [ConfigurationProperty ("varyByCustom")]
  120. public string VaryByCustom {
  121. get { return (string) base [varyByCustomProp];}
  122. set { base[varyByCustomProp] = value; }
  123. }
  124. [ConfigurationProperty ("varyByHeader")]
  125. public string VaryByHeader {
  126. get { return (string) base [varyByHeaderProp];}
  127. set { base[varyByHeaderProp] = value; }
  128. }
  129. [ConfigurationProperty ("varyByParam")]
  130. public string VaryByParam {
  131. get { return (string) base [varyByParamProp];}
  132. set { base[varyByParamProp] = value; }
  133. }
  134. protected override ConfigurationPropertyCollection Properties {
  135. get { return properties; }
  136. }
  137. }
  138. }
  139. #endif