WebServicesSection.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // System.Web.Services.Configuration.WebServicesSection
  3. //
  4. // Authors:
  5. // Chris Toshok ([email protected])
  6. //
  7. // (C) 2005 Novell, Inc (http://www.novell.com)
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.Configuration;
  32. using System.Web.Configuration;
  33. namespace System.Web.Services.Configuration
  34. {
  35. public sealed class WebServicesSection : ConfigurationSection
  36. {
  37. static ConfigurationProperty conformanceWarningsProp;
  38. static ConfigurationProperty diagnosticsProp;
  39. static ConfigurationProperty protocolsProp;
  40. static ConfigurationProperty serviceDescriptionFormatExtensionTypesProp;
  41. static ConfigurationProperty soapEnvelopeProcessingProp;
  42. static ConfigurationProperty soapExtensionImporterTypesProp;
  43. static ConfigurationProperty soapExtensionReflectorTypesProp;
  44. static ConfigurationProperty soapExtensionTypesProp;
  45. static ConfigurationProperty soapServerProtocolFactoryProp;
  46. static ConfigurationProperty soapTransportImporterTypesProp;
  47. static ConfigurationProperty wsdlHelpGeneratorProp;
  48. static ConfigurationPropertyCollection properties;
  49. static WebServicesSection ()
  50. {
  51. conformanceWarningsProp = new ConfigurationProperty ("conformanceWarnings", typeof (WsiProfilesElementCollection), null,
  52. null, null, ConfigurationPropertyOptions.None);
  53. diagnosticsProp = new ConfigurationProperty ("diagnostics", typeof (DiagnosticsElement), null,
  54. null, null, ConfigurationPropertyOptions.None);
  55. protocolsProp = new ConfigurationProperty ("protocols", typeof (ProtocolElementCollection), null,
  56. null, null, ConfigurationPropertyOptions.None);
  57. serviceDescriptionFormatExtensionTypesProp = new ConfigurationProperty ("serviceDescriptionFormatExtensionTypes", typeof (TypeElementCollection), null,
  58. null, null, ConfigurationPropertyOptions.None);
  59. soapEnvelopeProcessingProp = new ConfigurationProperty ("soapEnvelopeProcessing", typeof (SoapEnvelopeProcessingElement), null,
  60. null, null, ConfigurationPropertyOptions.None);
  61. soapExtensionImporterTypesProp = new ConfigurationProperty ("soapExtensionImporterTypes", typeof (TypeElementCollection), null,
  62. null, null, ConfigurationPropertyOptions.None);
  63. soapExtensionReflectorTypesProp = new ConfigurationProperty ("soapExtensionReflectorTypes", typeof (TypeElementCollection), null,
  64. null, null, ConfigurationPropertyOptions.None);
  65. soapExtensionTypesProp = new ConfigurationProperty ("soapExtensionTypes", typeof (SoapExtensionTypeElementCollection), null,
  66. null, null, ConfigurationPropertyOptions.None);
  67. soapServerProtocolFactoryProp = new ConfigurationProperty ("soapServerProtocolFactory", typeof (TypeElement), null,
  68. null, null, ConfigurationPropertyOptions.None);
  69. soapTransportImporterTypesProp = new ConfigurationProperty ("soapTransportImporterTypes", typeof (TypeElementCollection), null,
  70. null, null, ConfigurationPropertyOptions.None);
  71. wsdlHelpGeneratorProp = new ConfigurationProperty ("wsdlHelpGenerator", typeof (WsdlHelpGeneratorElement), null,
  72. null, null, ConfigurationPropertyOptions.None);
  73. properties = new ConfigurationPropertyCollection ();
  74. properties.Add (conformanceWarningsProp);
  75. properties.Add (diagnosticsProp);
  76. properties.Add (protocolsProp);
  77. properties.Add (serviceDescriptionFormatExtensionTypesProp);
  78. properties.Add (soapEnvelopeProcessingProp);
  79. properties.Add (soapExtensionImporterTypesProp);
  80. properties.Add (soapExtensionReflectorTypesProp);
  81. properties.Add (soapExtensionTypesProp);
  82. properties.Add (soapServerProtocolFactoryProp);
  83. properties.Add (soapTransportImporterTypesProp);
  84. properties.Add (wsdlHelpGeneratorProp);
  85. }
  86. public WebServicesSection GetSection (System.Configuration.Configuration config)
  87. {
  88. return (WebServicesSection)config.GetSection ("webServices");
  89. }
  90. protected override void InitializeDefault ()
  91. {
  92. }
  93. protected override void Reset (ConfigurationElement parentElement)
  94. {
  95. base.Reset (parentElement);
  96. }
  97. [ConfigurationProperty ("conformanceWarnings")]
  98. public WsiProfilesElementCollection ConformanceWarnings {
  99. get { return (WsiProfilesElementCollection) base [conformanceWarningsProp];}
  100. }
  101. [MonoTODO]
  102. public WebServicesSection Current {
  103. get { throw new NotImplementedException (); }
  104. }
  105. public DiagnosticsElement Diagnostics {
  106. get { return (DiagnosticsElement) base [diagnosticsProp]; }
  107. set { base[diagnosticsProp] = value; }
  108. }
  109. [MonoTODO]
  110. WebServiceProtocols enabledProtocols = WebServiceProtocols.Unknown;
  111. public WebServiceProtocols EnabledProtocols {
  112. get {
  113. if (enabledProtocols == WebServiceProtocols.Unknown) {
  114. foreach (ProtocolElement el in Protocols)
  115. enabledProtocols |= el.Name;
  116. }
  117. return enabledProtocols;
  118. }
  119. }
  120. [ConfigurationProperty ("protocols")]
  121. public ProtocolElementCollection Protocols {
  122. get { return (ProtocolElementCollection) base [protocolsProp];}
  123. }
  124. [ConfigurationProperty ("serviceDescriptionFormatExtensionTypes")]
  125. public TypeElementCollection ServiceDescriptionFormatExtensionTypes {
  126. get { return (TypeElementCollection) base [serviceDescriptionFormatExtensionTypesProp];}
  127. }
  128. [ConfigurationProperty ("soapEnvelopeProcessing")]
  129. public SoapEnvelopeProcessingElement SoapEnvelopeProcessing {
  130. get { return (SoapEnvelopeProcessingElement) base [soapEnvelopeProcessingProp];}
  131. set { base[soapEnvelopeProcessingProp] = value; }
  132. }
  133. [ConfigurationProperty ("soapExtensionImporterTypes")]
  134. public TypeElementCollection SoapExtensionImporterTypes {
  135. get { return (TypeElementCollection) base [soapExtensionImporterTypesProp];}
  136. }
  137. [ConfigurationProperty ("soapExtensionReflectorTypes")]
  138. public TypeElementCollection SoapExtensionReflectorTypes {
  139. get { return (TypeElementCollection) base [soapExtensionReflectorTypesProp];}
  140. }
  141. [ConfigurationProperty ("soapExtensionTypes")]
  142. public SoapExtensionTypeElementCollection SoapExtensionTypes {
  143. get { return (SoapExtensionTypeElementCollection) base [soapExtensionTypesProp];}
  144. }
  145. [ConfigurationProperty ("soapServerProtocolFactory")]
  146. public TypeElement SoapServerProtocolFactoryType {
  147. get { return (TypeElement) base [soapServerProtocolFactoryProp];}
  148. }
  149. [ConfigurationProperty("soapTransportImporterTypes")]
  150. public TypeElementCollection SoapTransportImporterTypes {
  151. get { return (TypeElementCollection) base [soapTransportImporterTypesProp];}
  152. }
  153. [ConfigurationProperty ("wsdlHelpGenerator")]
  154. public WsdlHelpGeneratorElement WsdlHelpGenerator {
  155. get { return (WsdlHelpGeneratorElement) base [wsdlHelpGeneratorProp];}
  156. }
  157. protected override ConfigurationPropertyCollection Properties {
  158. get { return properties; }
  159. }
  160. internal static WebServicesSection Instance {
  161. get { return (WebServicesSection)WebConfigurationManager.GetWebApplicationSection ("system.web/webServices"); }
  162. }
  163. internal static bool IsSupported (WebServiceProtocols proto)
  164. {
  165. return ((Instance.EnabledProtocols & proto) == proto && (proto != WebServiceProtocols.Unknown));
  166. }
  167. }
  168. }
  169. #endif