GlobalizationSection.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // System.Web.Configuration.GlobalizationSection
  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.Configuration;
  31. using System.Text;
  32. using System.Xml;
  33. #if NET_2_0
  34. namespace System.Web.Configuration {
  35. public sealed class GlobalizationSection : ConfigurationSection
  36. {
  37. static ConfigurationProperty cultureProp;
  38. static ConfigurationProperty enableBestFitResponseEncodingProp;
  39. static ConfigurationProperty enableClientBasedCultureProp;
  40. static ConfigurationProperty fileEncodingProp;
  41. static ConfigurationProperty requestEncodingProp;
  42. static ConfigurationProperty resourceProviderFactoryTypeProp;
  43. static ConfigurationProperty responseEncodingProp;
  44. static ConfigurationProperty responseHeaderEncodingProp;
  45. static ConfigurationProperty uiCultureProp;
  46. static ConfigurationPropertyCollection properties;
  47. static GlobalizationSection ()
  48. {
  49. cultureProp = new ConfigurationProperty ("culture", typeof (string), "");
  50. enableBestFitResponseEncodingProp = new ConfigurationProperty ("enableBestFitResponseEncoding", typeof (bool), false);
  51. enableClientBasedCultureProp = new ConfigurationProperty ("enableClientBasedCulture", typeof (bool), false);
  52. fileEncodingProp = new ConfigurationProperty ("fileEncoding", typeof (Encoding));
  53. requestEncodingProp = new ConfigurationProperty ("requestEncoding", typeof (Encoding), Encoding.UTF8);
  54. resourceProviderFactoryTypeProp = new ConfigurationProperty ("resourceProviderFactoryType", typeof (string), "");
  55. responseEncodingProp = new ConfigurationProperty ("responseEncoding", typeof (Encoding), Encoding.UTF8);
  56. responseHeaderEncodingProp = new ConfigurationProperty ("responseHeaderEncoding", typeof (Encoding), Encoding.UTF8);
  57. uiCultureProp = new ConfigurationProperty ("uiCulture", typeof (string), "");
  58. properties = new ConfigurationPropertyCollection ();
  59. properties.Add (cultureProp);
  60. properties.Add (enableBestFitResponseEncodingProp);
  61. properties.Add (enableClientBasedCultureProp);
  62. properties.Add (fileEncodingProp);
  63. properties.Add (requestEncodingProp);
  64. properties.Add (resourceProviderFactoryTypeProp);
  65. properties.Add (responseEncodingProp);
  66. properties.Add (responseHeaderEncodingProp);
  67. properties.Add (uiCultureProp);
  68. }
  69. [MonoTODO]
  70. protected override void PostDeserialize ()
  71. {
  72. base.PostDeserialize();
  73. }
  74. [MonoTODO]
  75. protected override void PreSerialize (XmlWriter writer)
  76. {
  77. base.PostDeserialize();
  78. }
  79. [ConfigurationProperty ("culture", DefaultValue = "")]
  80. public string Culture {
  81. get { return (string) base [cultureProp];}
  82. set { base[cultureProp] = value; }
  83. }
  84. [ConfigurationProperty ("enableBestFitResponseEncoding", DefaultValue = "False")]
  85. public bool EnableBestFitResponseEncoding {
  86. get { return (bool) base [enableBestFitResponseEncodingProp];}
  87. set { base[enableBestFitResponseEncodingProp] = value; }
  88. }
  89. [ConfigurationProperty ("enableClientBasedCulture", DefaultValue = "False")]
  90. public bool EnableClientBasedCulture {
  91. get { return (bool) base [enableClientBasedCultureProp];}
  92. set { base[enableClientBasedCultureProp] = value; }
  93. }
  94. [ConfigurationProperty ("fileEncoding")]
  95. public Encoding FileEncoding {
  96. get { return (Encoding) base [fileEncodingProp];}
  97. set { base[fileEncodingProp] = value; }
  98. }
  99. [ConfigurationProperty ("requestEncoding", DefaultValue = "utf-8")]
  100. public Encoding RequestEncoding {
  101. get { return (Encoding) base [requestEncodingProp];}
  102. set { base[requestEncodingProp] = value; }
  103. }
  104. [ConfigurationProperty ("resourceProviderFactoryType", DefaultValue = "")]
  105. public string ResourceProviderFactoryType {
  106. get { return (string) base [resourceProviderFactoryTypeProp];}
  107. set { base[resourceProviderFactoryTypeProp] = value; }
  108. }
  109. [ConfigurationProperty ("responseEncoding", DefaultValue = "utf-8")]
  110. public Encoding ResponseEncoding {
  111. get { return (Encoding) base [responseEncodingProp];}
  112. set { base[responseEncodingProp] = value; }
  113. }
  114. [ConfigurationProperty ("responseHeaderEncoding", DefaultValue = "utf-8")]
  115. public Encoding ResponseHeaderEncoding {
  116. get { return (Encoding) base [responseHeaderEncodingProp];}
  117. set { base[responseHeaderEncodingProp] = value; }
  118. }
  119. [ConfigurationProperty ("uiCulture", DefaultValue = "")]
  120. public string UICulture {
  121. get { return (string) base [uiCultureProp];}
  122. set { base[uiCultureProp] = value; }
  123. }
  124. protected override ConfigurationPropertyCollection Properties {
  125. get { return properties; }
  126. }
  127. }
  128. }
  129. #endif