WebServicesSection.cs 9.0 KB

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