merge -r 58784:58785
[mono.git] / mcs / class / System.Web / System.Web.Configuration_2.0 / ProfileSettings.cs
1 //
2 // System.Web.Configuration.ProfileSettings
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //
7 // (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9
10 //
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:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
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.
29 //
30
31 using System;
32 using System.ComponentModel;
33 using System.Configuration;
34
35 #if NET_2_0
36
37 namespace System.Web.Configuration {
38
39         public sealed class ProfileSettings : ConfigurationElement
40         {
41                 static ConfigurationProperty customProp;
42                 static ConfigurationProperty maxLimitProp;
43                 static ConfigurationProperty minInstancesProp;
44                 static ConfigurationProperty minIntervalProp;
45                 static ConfigurationProperty nameProp;
46                 static ConfigurationPropertyCollection properties;
47
48                 static ProfileSettings ()
49                 {
50                         customProp = new ConfigurationProperty ("custom", typeof (string), "");
51                         maxLimitProp = new ConfigurationProperty ("maxLimit", typeof (int), Int32.MaxValue);
52                         minInstancesProp = new ConfigurationProperty ("minInstances", typeof (int), 1);
53                         minIntervalProp = new ConfigurationProperty ("minInterval", typeof (TimeSpan), TimeSpan.FromSeconds (0));
54                         nameProp = new ConfigurationProperty ("name", typeof (string), "", ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey);
55                         properties = new ConfigurationPropertyCollection ();
56
57                         properties.Add (customProp);
58                         properties.Add (maxLimitProp);
59                         properties.Add (minInstancesProp);
60                         properties.Add (minIntervalProp);
61                         properties.Add (nameProp);
62
63                 }
64
65                 public ProfileSettings (string name)
66                 {
67                         this.Name = name;
68                 }
69
70                 public ProfileSettings (string name, int minInstances, int maxLimit, TimeSpan minInterval, string custom)
71                 {
72                         this.Name = name;
73                         this.MinInstances = minInstances;
74                         this.MaxLimit = maxLimit;
75                         this.MinInterval = MinInterval;
76                         this.Custom = custom;
77                 }
78
79                 public ProfileSettings (string name, int minInstances, int maxLimit, TimeSpan minInterval)
80                 {
81                         this.Name = name;
82                         this.MinInstances = minInstances;
83                         this.MaxLimit = maxLimit;
84                         this.MinInterval = MinInterval;
85                 }
86
87                 [ConfigurationProperty ("custom", DefaultValue = "")]
88                 public string Custom {
89                         get { return (string) base [customProp];}
90                         set { base[customProp] = value; }
91                 }
92
93                 [TypeConverter (typeof (InfiniteIntConverter))]
94                 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
95                 [ConfigurationProperty ("maxLimit", DefaultValue = Int32.MaxValue)]
96                 public int MaxLimit {
97                         get { return (int) base [maxLimitProp];}
98                         set { base[maxLimitProp] = value; }
99                 }
100
101                 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
102                 [ConfigurationProperty ("minInstances", DefaultValue = "1")]
103                 public int MinInstances {
104                         get { return (int) base [minInstancesProp];}
105                         set { base[minInstancesProp] = value; }
106                 }
107
108                 [TypeConverter (typeof (InfiniteTimeSpanConverter))]
109                 [ConfigurationProperty ("minInterval", DefaultValue = "00:00:00")]
110                 public TimeSpan MinInterval {
111                         get { return (TimeSpan) base [minIntervalProp];}
112                         set { base[minIntervalProp] = value; }
113                 }
114
115                 [StringValidator (MinLength = 1)]
116                 [ConfigurationProperty ("name", DefaultValue = "", Options = ConfigurationPropertyOptions.IsRequired | ConfigurationPropertyOptions.IsKey)]
117                 public string Name {
118                         get { return (string) base [nameProp];}
119                         set { base[nameProp] = value; }
120                 }
121
122                 protected override ConfigurationPropertyCollection Properties {
123                         get { return properties; }
124                 }
125
126         }
127
128 }
129
130 #endif
131