BufferModeSettings.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //
  2. // System.Web.Configuration.BufferModeSettings
  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. #if NET_2_0
  33. namespace System.Web.Configuration {
  34. public sealed class BufferModeSettings : ConfigurationElement
  35. {
  36. static ConfigurationProperty maxBufferSizeProp;
  37. static ConfigurationProperty maxBufferThreadsProp;
  38. static ConfigurationProperty maxFlushSizeProp;
  39. static ConfigurationProperty nameProp;
  40. static ConfigurationProperty regularFlushIntervalProp;
  41. static ConfigurationProperty urgentFlushIntervalProp;
  42. static ConfigurationProperty urgentFlushThresholdProp;
  43. static ConfigurationPropertyCollection properties;
  44. static BufferModeSettings ()
  45. {
  46. IntegerValidator iv = new IntegerValidator (1, Int32.MaxValue);
  47. maxBufferSizeProp = new ConfigurationProperty ("maxBufferSize", typeof (int), Int32.MaxValue,
  48. PropertyHelper.InfiniteIntConverter, iv,
  49. ConfigurationPropertyOptions.IsRequired);
  50. maxBufferThreadsProp = new ConfigurationProperty ("maxBufferThreads", typeof (int), 1,
  51. PropertyHelper.InfiniteIntConverter, iv,
  52. ConfigurationPropertyOptions.None);
  53. maxFlushSizeProp = new ConfigurationProperty ("maxFlushSize", typeof (int), Int32.MaxValue,
  54. PropertyHelper.InfiniteIntConverter, iv,
  55. ConfigurationPropertyOptions.IsRequired);
  56. nameProp = new ConfigurationProperty ("name", typeof (string), "",
  57. TypeDescriptor.GetConverter (typeof (string)), PropertyHelper.NonEmptyStringValidator,
  58. ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
  59. regularFlushIntervalProp = new ConfigurationProperty ("regularFlushInterval", typeof (TimeSpan), TimeSpan.FromSeconds (1),
  60. PropertyHelper.InfiniteTimeSpanConverter,
  61. PropertyHelper.PositiveTimeSpanValidator,
  62. ConfigurationPropertyOptions.IsRequired);
  63. urgentFlushIntervalProp = new ConfigurationProperty ("urgentFlushInterval", typeof (TimeSpan), TimeSpan.FromSeconds (0),
  64. PropertyHelper.InfiniteTimeSpanConverter, null,
  65. ConfigurationPropertyOptions.IsRequired);
  66. urgentFlushThresholdProp = new ConfigurationProperty ("urgentFlushThreshold", typeof (int), Int32.MaxValue,
  67. PropertyHelper.InfiniteIntConverter, iv,
  68. ConfigurationPropertyOptions.IsRequired);
  69. properties = new ConfigurationPropertyCollection ();
  70. properties.Add (nameProp);
  71. properties.Add (maxBufferSizeProp);
  72. properties.Add (maxBufferThreadsProp);
  73. properties.Add (maxFlushSizeProp);
  74. properties.Add (regularFlushIntervalProp);
  75. properties.Add (urgentFlushIntervalProp);
  76. properties.Add (urgentFlushThresholdProp);
  77. }
  78. internal BufferModeSettings ()
  79. {
  80. }
  81. public BufferModeSettings (string name, int maxBufferSize, int maxFlushSize, int urgentFlushThreshold,
  82. TimeSpan regularFlushInterval, TimeSpan urgentFlushInterval, int maxBufferThreads)
  83. {
  84. this.Name = name;
  85. this.MaxBufferSize = maxBufferSize;
  86. this.MaxFlushSize = maxFlushSize;
  87. this.UrgentFlushThreshold = urgentFlushThreshold;
  88. this.RegularFlushInterval = regularFlushInterval;
  89. this.UrgentFlushInterval = urgentFlushInterval;
  90. this.MaxBufferThreads = maxBufferThreads;
  91. }
  92. #if notyet
  93. protected override ConfigurationElementProperty ElementProperty {
  94. get { }
  95. }
  96. #endif
  97. [TypeConverter (typeof (InfiniteIntConverter))]
  98. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
  99. [ConfigurationProperty ("maxBufferSize", DefaultValue = "2147483647", Options = ConfigurationPropertyOptions.IsRequired)]
  100. public int MaxBufferSize {
  101. get { return (int) base [maxBufferSizeProp];}
  102. set { base[maxBufferSizeProp] = value; }
  103. }
  104. [TypeConverter (typeof (InfiniteIntConverter))]
  105. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
  106. [ConfigurationProperty ("maxBufferThreads", DefaultValue = "1")]
  107. public int MaxBufferThreads {
  108. get { return (int) base [maxBufferThreadsProp];}
  109. set { base[maxBufferThreadsProp] = value; }
  110. }
  111. [TypeConverter (typeof (InfiniteIntConverter))]
  112. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
  113. [ConfigurationProperty ("maxFlushSize", DefaultValue = "2147483647", Options = ConfigurationPropertyOptions.IsRequired)]
  114. public int MaxFlushSize {
  115. get { return (int) base [maxFlushSizeProp];}
  116. set { base[maxFlushSizeProp] = value; }
  117. }
  118. [StringValidator (MinLength = 1)]
  119. [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
  120. public string Name {
  121. get { return (string) base [nameProp];}
  122. set { base[nameProp] = value; }
  123. }
  124. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  125. [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
  126. [ConfigurationProperty ("regularFlushInterval", DefaultValue = "00:00:01", Options = ConfigurationPropertyOptions.IsRequired)]
  127. public TimeSpan RegularFlushInterval {
  128. get { return (TimeSpan) base [regularFlushIntervalProp];}
  129. set { base[regularFlushIntervalProp] = value; }
  130. }
  131. [TypeConverter (typeof (InfiniteTimeSpanConverter))]
  132. [ConfigurationProperty ("urgentFlushInterval", DefaultValue = "00:00:00", Options = ConfigurationPropertyOptions.IsRequired)]
  133. public TimeSpan UrgentFlushInterval {
  134. get { return (TimeSpan) base [urgentFlushIntervalProp];}
  135. set { base[urgentFlushIntervalProp] = value; }
  136. }
  137. [TypeConverter (typeof (InfiniteIntConverter))]
  138. [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
  139. [ConfigurationProperty ("urgentFlushThreshold", DefaultValue = "2147483647", Options = ConfigurationPropertyOptions.IsRequired)]
  140. public int UrgentFlushThreshold {
  141. get { return (int) base [urgentFlushThresholdProp];}
  142. set { base[urgentFlushThresholdProp] = value; }
  143. }
  144. protected override ConfigurationPropertyCollection Properties {
  145. get { return properties; }
  146. }
  147. }
  148. }
  149. #endif