OutputCacheSection.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //
  2. // System.Web.Configuration.OutputCacheSection
  3. //
  4. // Authors:
  5. // Chris Toshok ([email protected])
  6. //
  7. // (C) 2005-2010 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.Configuration;
  31. namespace System.Web.Configuration
  32. {
  33. public sealed class OutputCacheSection : ConfigurationSection
  34. {
  35. static ConfigurationProperty enableFragmentCacheProp;
  36. static ConfigurationProperty enableOutputCacheProp;
  37. static ConfigurationProperty omitVaryStarProp;
  38. static ConfigurationProperty sendCacheControlHeaderProp;
  39. static ConfigurationProperty enableKernelCacheForVaryByStarProp;
  40. #if NET_4_0
  41. static ConfigurationProperty providersProp;
  42. static ConfigurationProperty defaultProviderNameProp;
  43. #endif
  44. static ConfigurationPropertyCollection properties;
  45. static OutputCacheSection ()
  46. {
  47. enableFragmentCacheProp = new ConfigurationProperty ("enableFragmentCache", typeof (bool), true);
  48. enableOutputCacheProp = new ConfigurationProperty ("enableOutputCache", typeof (bool), true);
  49. omitVaryStarProp = new ConfigurationProperty ("omitVaryStar", typeof (bool), false);
  50. sendCacheControlHeaderProp = new ConfigurationProperty ("sendCacheControlHeader", typeof (bool), true);
  51. enableKernelCacheForVaryByStarProp = new ConfigurationProperty ("enableKernelCacheForVaryByStar", typeof (bool), false);
  52. #if NET_4_0
  53. providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection));
  54. defaultProviderNameProp = new ConfigurationProperty ("defaultProvider", typeof (string), "AspNetInternalProvider");
  55. #endif
  56. properties = new ConfigurationPropertyCollection ();
  57. properties.Add (enableFragmentCacheProp);
  58. properties.Add (enableOutputCacheProp);
  59. properties.Add (omitVaryStarProp);
  60. properties.Add (sendCacheControlHeaderProp);
  61. properties.Add (enableKernelCacheForVaryByStarProp);
  62. #if NET_4_0
  63. properties.Add (providersProp);
  64. properties.Add (defaultProviderNameProp);
  65. #endif
  66. }
  67. [ConfigurationProperty ("enableFragmentCache", DefaultValue = "True")]
  68. public bool EnableFragmentCache {
  69. get { return (bool) base [enableFragmentCacheProp];}
  70. set { base[enableFragmentCacheProp] = value; }
  71. }
  72. [ConfigurationProperty ("enableOutputCache", DefaultValue = "True")]
  73. public bool EnableOutputCache {
  74. get { return (bool) base [enableOutputCacheProp];}
  75. set { base[enableOutputCacheProp] = value; }
  76. }
  77. [ConfigurationProperty ("enableKernelCacheForVaryByStar", DefaultValue = "False")]
  78. public bool EnableKernelCacheForVaryByStar {
  79. get { return (bool) base [enableKernelCacheForVaryByStarProp]; }
  80. set { base [enableKernelCacheForVaryByStarProp] = value; }
  81. }
  82. [ConfigurationProperty ("omitVaryStar", DefaultValue = "False")]
  83. public bool OmitVaryStar {
  84. get { return (bool) base [omitVaryStarProp];}
  85. set { base[omitVaryStarProp] = value; }
  86. }
  87. [ConfigurationProperty ("sendCacheControlHeader", DefaultValue = "True")]
  88. public bool SendCacheControlHeader {
  89. get { return (bool) base [sendCacheControlHeaderProp];}
  90. set { base[sendCacheControlHeaderProp] = value; }
  91. }
  92. #if NET_4_0
  93. [StringValidatorAttribute(MinLength = 1)]
  94. [ConfigurationPropertyAttribute("defaultProvider", DefaultValue = "AspNetInternalProvider")]
  95. public string DefaultProviderName {
  96. get { return base [defaultProviderNameProp] as string; }
  97. set { base [defaultProviderNameProp] = value; }
  98. }
  99. [ConfigurationPropertyAttribute("providers")]
  100. public ProviderSettingsCollection Providers {
  101. get { return base [providersProp] as ProviderSettingsCollection; }
  102. }
  103. #endif
  104. protected override ConfigurationPropertyCollection Properties {
  105. get { return properties; }
  106. }
  107. }
  108. }