2 // System.Web.Configuration.RuleSettings
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 RuleSettings
: ConfigurationElement
41 static ConfigurationProperty customProp
;
42 static ConfigurationProperty eventNameProp
;
43 static ConfigurationProperty maxLimitProp
;
44 static ConfigurationProperty minInstancesProp
;
45 static ConfigurationProperty minIntervalProp
;
46 static ConfigurationProperty nameProp
;
47 static ConfigurationProperty profileProp
;
48 static ConfigurationProperty providerProp
;
49 static ConfigurationPropertyCollection properties
;
51 static RuleSettings ()
53 customProp
= new ConfigurationProperty ("custom", typeof (string), "");
54 eventNameProp
= new ConfigurationProperty ("eventName", typeof (string), "", ConfigurationPropertyOptions
.IsRequired
);
55 maxLimitProp
= new ConfigurationProperty ("maxLimit", typeof (int), Int32
.MaxValue
,
56 PropertyHelper
.InfiniteIntConverter
,
57 PropertyHelper
.IntFromZeroToMaxValidator
,
58 ConfigurationPropertyOptions
.None
);
59 minInstancesProp
= new ConfigurationProperty ("minInstances", typeof (int), 1,
60 TypeDescriptor
.GetConverter (typeof (int)),
61 new IntegerValidator (1, Int32
.MaxValue
),
62 ConfigurationPropertyOptions
.None
);
63 minIntervalProp
= new ConfigurationProperty ("minInterval", typeof (TimeSpan
), TimeSpan
.FromSeconds (0),
64 PropertyHelper
.InfiniteTimeSpanConverter
, null,
65 ConfigurationPropertyOptions
.None
);
66 nameProp
= new ConfigurationProperty ("name", typeof (string), "",
67 TypeDescriptor
.GetConverter (typeof (string)),
68 PropertyHelper
.NonEmptyStringValidator
,
69 ConfigurationPropertyOptions
.IsRequired
| ConfigurationPropertyOptions
.IsKey
);
70 profileProp
= new ConfigurationProperty ("profile", typeof (string), "");
71 providerProp
= new ConfigurationProperty ("provider", typeof (string), "");
72 properties
= new ConfigurationPropertyCollection ();
74 properties
.Add (customProp
);
75 properties
.Add (eventNameProp
);
76 properties
.Add (maxLimitProp
);
77 properties
.Add (minInstancesProp
);
78 properties
.Add (minIntervalProp
);
79 properties
.Add (nameProp
);
80 properties
.Add (profileProp
);
81 properties
.Add (providerProp
);
84 internal RuleSettings ()
88 public RuleSettings (string name
, string eventName
, string provider
, string profile
, int minInstances
, int maxLimit
, TimeSpan minInterval
, string custom
)
91 this.EventName
= eventName
;
92 this.Provider
= provider
;
93 this.Profile
= profile
;
94 this.MinInstances
= minInstances
;
95 this.MaxLimit
= maxLimit
;
96 this.MinInterval
= minInterval
;
100 public RuleSettings (string name
, string eventName
, string provider
, string profile
, int minInstances
, int maxLimit
, TimeSpan minInterval
)
103 this.EventName
= eventName
;
104 this.Provider
= provider
;
105 this.Profile
= profile
;
106 this.MinInstances
= minInstances
;
107 this.MaxLimit
= maxLimit
;
108 this.MinInterval
= minInterval
;
111 public RuleSettings (string name
, string eventName
, string provider
)
114 this.EventName
= eventName
;
115 this.Provider
= provider
;
118 [ConfigurationProperty ("custom", DefaultValue
= "")]
119 public string Custom
{
120 get { return (string) base [customProp];}
121 set { base[customProp] = value; }
124 [ConfigurationProperty ("eventName", DefaultValue
= "", Options
= ConfigurationPropertyOptions
.IsRequired
)]
125 public string EventName
{
126 get { return (string) base [eventNameProp];}
127 set { base[eventNameProp] = value; }
130 [TypeConverter (typeof (InfiniteIntConverter
))]
131 [IntegerValidator (MinValue
= 0, MaxValue
= Int32
.MaxValue
)]
132 [ConfigurationProperty ("maxLimit", DefaultValue
= "2147483647")]
133 public int MaxLimit
{
134 get { return (int) base [maxLimitProp];}
135 set { base[maxLimitProp] = value; }
138 [IntegerValidator (MinValue
= 1, MaxValue
= Int32
.MaxValue
)]
139 [ConfigurationProperty ("minInstances", DefaultValue
= "1")]
140 public int MinInstances
{
141 get { return (int) base [minInstancesProp];}
142 set { base[minInstancesProp] = value; }
145 [TypeConverter (typeof (InfiniteTimeSpanConverter
))]
146 [ConfigurationProperty ("minInterval", DefaultValue
= "00:00:00")]
147 public TimeSpan MinInterval
{
148 get { return (TimeSpan) base [minIntervalProp];}
149 set { base[minIntervalProp] = value; }
152 [StringValidator (MinLength
= 1)]
153 [ConfigurationProperty ("name", DefaultValue
= "", Options
= ConfigurationPropertyOptions
.IsRequired
| ConfigurationPropertyOptions
.IsKey
)]
155 get { return (string) base [nameProp];}
156 set { base[nameProp] = value; }
159 [ConfigurationProperty ("profile", DefaultValue
= "")]
160 public string Profile
{
161 get { return (string) base [profileProp];}
162 set { base[profileProp] = value; }
165 [ConfigurationProperty ("provider", DefaultValue
= "")]
166 public string Provider
{
167 get { return (string) base [providerProp];}
168 set { base[providerProp] = value; }
171 protected override ConfigurationPropertyCollection Properties
{
172 get { return properties; }