2 // System.Web.Configuration.BufferModeSettings
5 // Chris Toshok (toshok@ximian.com)
7 // (C) 2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.ComponentModel;
33 using System.Configuration;
37 namespace System.Web.Configuration {
39 public sealed class BufferModeSettings : ConfigurationElement
41 static ConfigurationProperty maxBufferSizeProp;
42 static ConfigurationProperty maxBufferThreadsProp;
43 static ConfigurationProperty maxFlushSizeProp;
44 static ConfigurationProperty nameProp;
45 static ConfigurationProperty regularFlushIntervalProp;
46 static ConfigurationProperty urgentFlushIntervalProp;
47 static ConfigurationProperty urgentFlushThresholdProp;
48 static ConfigurationPropertyCollection properties;
49 static ConfigurationElementProperty elementProperty;
51 static BufferModeSettings ()
53 IntegerValidator iv = new IntegerValidator (1, Int32.MaxValue);
55 maxBufferSizeProp = new ConfigurationProperty ("maxBufferSize", typeof (int), Int32.MaxValue,
56 PropertyHelper.InfiniteIntConverter, iv,
57 ConfigurationPropertyOptions.IsRequired);
58 maxBufferThreadsProp = new ConfigurationProperty ("maxBufferThreads", typeof (int), 1,
59 PropertyHelper.InfiniteIntConverter, iv,
60 ConfigurationPropertyOptions.None);
61 maxFlushSizeProp = new ConfigurationProperty ("maxFlushSize", typeof (int), Int32.MaxValue,
62 PropertyHelper.InfiniteIntConverter, iv,
63 ConfigurationPropertyOptions.IsRequired);
64 nameProp = new ConfigurationProperty ("name", typeof (string), "",
65 TypeDescriptor.GetConverter (typeof (string)), PropertyHelper.NonEmptyStringValidator,
66 ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
67 regularFlushIntervalProp = new ConfigurationProperty ("regularFlushInterval", typeof (TimeSpan), TimeSpan.FromSeconds (1),
68 PropertyHelper.InfiniteTimeSpanConverter,
69 PropertyHelper.PositiveTimeSpanValidator,
70 ConfigurationPropertyOptions.IsRequired);
71 urgentFlushIntervalProp = new ConfigurationProperty ("urgentFlushInterval", typeof (TimeSpan), TimeSpan.FromSeconds (0),
72 PropertyHelper.InfiniteTimeSpanConverter, null,
73 ConfigurationPropertyOptions.IsRequired);
74 urgentFlushThresholdProp = new ConfigurationProperty ("urgentFlushThreshold", typeof (int), Int32.MaxValue,
75 PropertyHelper.InfiniteIntConverter, iv,
76 ConfigurationPropertyOptions.IsRequired);
77 properties = new ConfigurationPropertyCollection ();
79 properties.Add (nameProp);
80 properties.Add (maxBufferSizeProp);
81 properties.Add (maxBufferThreadsProp);
82 properties.Add (maxFlushSizeProp);
83 properties.Add (regularFlushIntervalProp);
84 properties.Add (urgentFlushIntervalProp);
85 properties.Add (urgentFlushThresholdProp);
87 elementProperty = new ConfigurationElementProperty (new CallbackValidator (typeof (BufferModeSettings), ValidateElement));
90 internal BufferModeSettings ()
94 public BufferModeSettings (string name, int maxBufferSize, int maxFlushSize, int urgentFlushThreshold,
95 TimeSpan regularFlushInterval, TimeSpan urgentFlushInterval, int maxBufferThreads)
98 this.MaxBufferSize = maxBufferSize;
99 this.MaxFlushSize = maxFlushSize;
100 this.UrgentFlushThreshold = urgentFlushThreshold;
101 this.RegularFlushInterval = regularFlushInterval;
102 this.UrgentFlushInterval = urgentFlushInterval;
103 this.MaxBufferThreads = maxBufferThreads;
106 [MonoTODO("Should do some validation here")]
107 static void ValidateElement (object o)
109 /* XXX do some sort of element validation here? */
112 protected override ConfigurationElementProperty ElementProperty {
113 get { return elementProperty; }
116 [TypeConverter (typeof (InfiniteIntConverter))]
117 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
118 [ConfigurationProperty ("maxBufferSize", DefaultValue = "2147483647", Options = ConfigurationPropertyOptions.IsRequired)]
119 public int MaxBufferSize {
120 get { return (int) base [maxBufferSizeProp];}
121 set { base[maxBufferSizeProp] = value; }
124 [TypeConverter (typeof (InfiniteIntConverter))]
125 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
126 [ConfigurationProperty ("maxBufferThreads", DefaultValue = "1")]
127 public int MaxBufferThreads {
128 get { return (int) base [maxBufferThreadsProp];}
129 set { base[maxBufferThreadsProp] = value; }
132 [TypeConverter (typeof (InfiniteIntConverter))]
133 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
134 [ConfigurationProperty ("maxFlushSize", DefaultValue = "2147483647", Options = ConfigurationPropertyOptions.IsRequired)]
135 public int MaxFlushSize {
136 get { return (int) base [maxFlushSizeProp];}
137 set { base[maxFlushSizeProp] = value; }
140 [StringValidator (MinLength = 1)]
141 [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
143 get { return (string) base [nameProp];}
144 set { base[nameProp] = value; }
147 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
148 [TimeSpanValidator (MinValueString = "00:00:00", MaxValueString = "10675199.02:48:05.4775807")]
149 [ConfigurationProperty ("regularFlushInterval", DefaultValue = "00:00:01", Options = ConfigurationPropertyOptions.IsRequired)]
150 public TimeSpan RegularFlushInterval {
151 get { return (TimeSpan) base [regularFlushIntervalProp];}
152 set { base[regularFlushIntervalProp] = value; }
155 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
156 [ConfigurationProperty ("urgentFlushInterval", DefaultValue = "00:00:00", Options = ConfigurationPropertyOptions.IsRequired)]
157 public TimeSpan UrgentFlushInterval {
158 get { return (TimeSpan) base [urgentFlushIntervalProp];}
159 set { base[urgentFlushIntervalProp] = value; }
162 [TypeConverter (typeof (InfiniteIntConverter))]
163 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
164 [ConfigurationProperty ("urgentFlushThreshold", DefaultValue = "2147483647", Options = ConfigurationPropertyOptions.IsRequired)]
165 public int UrgentFlushThreshold {
166 get { return (int) base [urgentFlushThresholdProp];}
167 set { base[urgentFlushThresholdProp] = value; }
170 protected override ConfigurationPropertyCollection Properties {
171 get { return properties; }