BufferModeSettings.cs 6.8 KB

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