2009-04-20 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Configuration / WebServicesSection.cs
1 //
2 // System.Web.Services.Configuration.WebServicesSection
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 #if NET_2_0
32
33 using System;
34 using System.Configuration;
35 using System.Web.Configuration;
36
37 namespace System.Web.Services.Configuration
38 {
39         public sealed class WebServicesSection : ConfigurationSection
40         {
41                 static ConfigurationProperty conformanceWarningsProp;
42                 static ConfigurationProperty diagnosticsProp;
43                 static ConfigurationProperty protocolsProp;
44                 static ConfigurationProperty serviceDescriptionFormatExtensionTypesProp;
45                 static ConfigurationProperty soapEnvelopeProcessingProp;
46                 static ConfigurationProperty soapExtensionImporterTypesProp;
47                 static ConfigurationProperty soapExtensionReflectorTypesProp;
48                 static ConfigurationProperty soapExtensionTypesProp;
49                 static ConfigurationProperty soapServerProtocolFactoryProp;
50                 static ConfigurationProperty soapTransportImporterTypesProp;
51                 static ConfigurationProperty wsdlHelpGeneratorProp;
52                 static ConfigurationPropertyCollection properties;
53
54                 static WebServicesSection ()
55                 {
56                         conformanceWarningsProp = new ConfigurationProperty ("conformanceWarnings", typeof (WsiProfilesElementCollection), null,
57                                                                              null, null, ConfigurationPropertyOptions.None);
58                         diagnosticsProp = new ConfigurationProperty ("diagnostics", typeof (DiagnosticsElement), null,
59                                                                      null, null, ConfigurationPropertyOptions.None);
60                         protocolsProp = new ConfigurationProperty ("protocols", typeof (ProtocolElementCollection), null,
61                                                                    null, null, ConfigurationPropertyOptions.None);
62                         serviceDescriptionFormatExtensionTypesProp = new ConfigurationProperty ("serviceDescriptionFormatExtensionTypes", typeof (TypeElementCollection), null,
63                                                                                                 null, null, ConfigurationPropertyOptions.None);
64                         soapEnvelopeProcessingProp = new ConfigurationProperty ("soapEnvelopeProcessing", typeof (SoapEnvelopeProcessingElement), null,
65                                                                                 null, null, ConfigurationPropertyOptions.None);
66                         soapExtensionImporterTypesProp = new ConfigurationProperty ("soapExtensionImporterTypes", typeof (TypeElementCollection), null,
67                                                                                     null, null, ConfigurationPropertyOptions.None);
68                         soapExtensionReflectorTypesProp = new ConfigurationProperty ("soapExtensionReflectorTypes", typeof (TypeElementCollection), null,
69                                                                                      null, null, ConfigurationPropertyOptions.None);
70                         soapExtensionTypesProp = new ConfigurationProperty ("soapExtensionTypes", typeof (SoapExtensionTypeElementCollection), null,
71                                                                             null, null, ConfigurationPropertyOptions.None);
72                         soapServerProtocolFactoryProp = new ConfigurationProperty ("soapServerProtocolFactory", typeof (TypeElement), null,
73                                                                                    null, null, ConfigurationPropertyOptions.None);
74                         soapTransportImporterTypesProp = new ConfigurationProperty ("soapTransportImporterTypes", typeof (TypeElementCollection), null,
75                                                                                     null, null, ConfigurationPropertyOptions.None);
76                         wsdlHelpGeneratorProp = new ConfigurationProperty ("wsdlHelpGenerator", typeof (WsdlHelpGeneratorElement), null,
77                                                                            null, null, ConfigurationPropertyOptions.None);
78                         properties = new ConfigurationPropertyCollection ();
79
80                         properties.Add (conformanceWarningsProp);
81                         properties.Add (diagnosticsProp);
82                         properties.Add (protocolsProp);
83                         properties.Add (serviceDescriptionFormatExtensionTypesProp);
84                         properties.Add (soapEnvelopeProcessingProp);
85                         properties.Add (soapExtensionImporterTypesProp);
86                         properties.Add (soapExtensionReflectorTypesProp);
87                         properties.Add (soapExtensionTypesProp);
88                         properties.Add (soapServerProtocolFactoryProp);
89                         properties.Add (soapTransportImporterTypesProp);
90                         properties.Add (wsdlHelpGeneratorProp);
91
92                 }
93
94                 public static WebServicesSection GetSection (System.Configuration.Configuration config)
95                 {
96                         return (WebServicesSection) config.GetSection ("webServices");
97                 }
98
99                 protected override void InitializeDefault ()
100                 {
101                 }
102
103                 protected override void Reset (ConfigurationElement parentElement)
104                 {
105                         base.Reset (parentElement);
106                 }
107
108                 [ConfigurationProperty ("conformanceWarnings")]
109                 public WsiProfilesElementCollection ConformanceWarnings {
110                         get { return (WsiProfilesElementCollection) base [conformanceWarningsProp];}
111                 }
112
113                 public DiagnosticsElement Diagnostics {
114                         get { return (DiagnosticsElement) base [diagnosticsProp]; }
115                         set { base[diagnosticsProp] = value; }
116                 }
117
118                 [MonoTODO]
119                 WebServiceProtocols enabledProtocols = WebServiceProtocols.Unknown;
120                 public WebServiceProtocols EnabledProtocols {
121                         get {
122                                 if (enabledProtocols == WebServiceProtocols.Unknown) {
123                                         foreach (ProtocolElement el in Protocols)
124                                                 enabledProtocols |= el.Name;
125                                 }
126
127                                 return enabledProtocols;
128                         }
129                 }
130
131                 [ConfigurationProperty ("protocols")]
132                 public ProtocolElementCollection Protocols {
133                         get { return (ProtocolElementCollection) base [protocolsProp];}
134                 }
135
136                 [ConfigurationProperty ("serviceDescriptionFormatExtensionTypes")]
137                 public TypeElementCollection ServiceDescriptionFormatExtensionTypes {
138                         get { return (TypeElementCollection) base [serviceDescriptionFormatExtensionTypesProp];}
139                 }
140
141                 [ConfigurationProperty ("soapEnvelopeProcessing")]
142                 public SoapEnvelopeProcessingElement SoapEnvelopeProcessing {
143                         get { return (SoapEnvelopeProcessingElement) base [soapEnvelopeProcessingProp];}
144                         set { base[soapEnvelopeProcessingProp] = value; }
145                 }
146
147                 [ConfigurationProperty ("soapExtensionImporterTypes")]
148                 public TypeElementCollection SoapExtensionImporterTypes {
149                         get { return (TypeElementCollection) base [soapExtensionImporterTypesProp];}
150                 }
151
152                 [ConfigurationProperty ("soapExtensionReflectorTypes")]
153                 public TypeElementCollection SoapExtensionReflectorTypes {
154                         get { return (TypeElementCollection) base [soapExtensionReflectorTypesProp];}
155                 }
156
157                 [ConfigurationProperty ("soapExtensionTypes")]
158                 public SoapExtensionTypeElementCollection SoapExtensionTypes {
159                         get { return (SoapExtensionTypeElementCollection) base [soapExtensionTypesProp];}
160                 }
161
162                 [ConfigurationProperty ("soapServerProtocolFactory")]
163                 public TypeElement SoapServerProtocolFactoryType {
164                         get { return (TypeElement) base [soapServerProtocolFactoryProp];}
165                 }
166
167                 [ConfigurationProperty("soapTransportImporterTypes")]
168                 public TypeElementCollection SoapTransportImporterTypes {
169                         get { return (TypeElementCollection) base [soapTransportImporterTypesProp];}
170                 }
171
172                 [ConfigurationProperty ("wsdlHelpGenerator")]
173                 public WsdlHelpGeneratorElement WsdlHelpGenerator {
174                         get { return (WsdlHelpGeneratorElement) base [wsdlHelpGeneratorProp];}
175                 }
176
177                 protected override ConfigurationPropertyCollection Properties {
178                         get { return properties; }
179                 }
180
181                 public static WebServicesSection Current {
182                         get { return (WebServicesSection) ConfigurationManager.GetSection ("system.web/webServices"); }
183                 }
184
185                 internal static bool IsSupported (WebServiceProtocols proto)
186                 {
187                         return ((Current.EnabledProtocols & proto) == proto && (proto != WebServiceProtocols.Unknown));
188                 }
189         }
190
191 }
192
193 #endif