Fix SOAP configuration error
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Configuration / SoapExtensionTypeElement.cs
1 //
2 // System.Web.Services.Configuration.SoapExtensionTypeElement
3 //
4 // Authors:
5 //      Chris Toshok (toshok@ximian.com)
6 //      Atsushi Enomoto (atsushi@ximian.com)
7 //
8 // (C) 2006-2007 Novell, Inc (http://www.novell.com)
9 //
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using System;
33 using System.Configuration;
34 using System.ComponentModel;
35 using System.Globalization;
36 using System.Security.Permissions;
37
38 #if NET_2_0
39
40 namespace System.Web.Services.Configuration {
41
42         public sealed class SoapExtensionTypeElement : ConfigurationElement
43         {
44                 static ConfigurationProperty groupProp;
45                 static ConfigurationProperty priorityProp;
46                 static ConfigurationProperty typeProp;
47                 static ConfigurationPropertyCollection properties;
48
49                 static SoapExtensionTypeElement ()
50                 {
51                         groupProp = new ConfigurationProperty ("group", typeof (PriorityGroup), PriorityGroup.Low, ConfigurationPropertyOptions.IsKey);
52                         priorityProp = new ConfigurationProperty ("priority", typeof (int), 0,
53                                                                   new Int32Converter(), new IntegerValidator (0, Int32.MaxValue),
54                                                                   ConfigurationPropertyOptions.IsKey);
55                         typeProp = new ConfigurationProperty ("type", typeof (Type), null,
56                                                               new TypeTypeConverter (),
57                                                               null, ConfigurationPropertyOptions.IsKey);
58                         properties = new ConfigurationPropertyCollection ();
59
60                         properties.Add (groupProp);
61                         properties.Add (priorityProp);
62                         properties.Add (typeProp);
63
64                 }
65
66                 public SoapExtensionTypeElement (Type type, int priority, PriorityGroup group)
67                 {
68                         this.Type = type;
69                         this.Priority = priority;
70                         this.Group = group;
71                 }
72
73                 [MonoTODO]
74                 public SoapExtensionTypeElement (string type, int priority, PriorityGroup group)
75                         : this (Type.GetType (type), priority, group)
76                 {
77                 }
78
79                 public SoapExtensionTypeElement ()
80                 {
81                 }
82    
83                 [ConfigurationProperty ("group", DefaultValue = PriorityGroup.Low, Options = ConfigurationPropertyOptions.IsKey)]
84                 public PriorityGroup Group {
85                         get { return (PriorityGroup) base [groupProp];}
86                         set { base[groupProp] = value; }
87                 }
88
89                 [IntegerValidator (MaxValue = int.MaxValue)]
90                 [ConfigurationProperty ("priority", DefaultValue = 0, Options = ConfigurationPropertyOptions.IsKey)]
91                 public int Priority {
92                         get { return (int) base [priorityProp];}
93                         set { base[priorityProp] = value; }
94                 }
95
96                 [TypeConverter (typeof (TypeTypeConverter))]
97                 [ConfigurationProperty ("type", Options = ConfigurationPropertyOptions.IsKey)]
98                 public Type Type {
99                         get { return (Type) base [typeProp];}
100                         set { base[typeProp] = value; }
101                 }
102
103                 internal object GetKey ()
104                 {
105                         return String.Format ("{0}-{0}-{0}", Type, Priority, Group);
106                 }
107
108                 protected override ConfigurationPropertyCollection Properties {
109                         get { return properties; }
110                 }
111
112         }
113 }
114
115 #endif
116