WebHttpEndpointElement.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // Author:
  3. // Atsushi Enomoto <[email protected]>
  4. //
  5. // Copyright (C) 2010 Novell, Inc. http://www.novell.com
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining
  8. // a copy of this software and associated documentation files (the
  9. // "Software"), to deal in the Software without restriction, including
  10. // without limitation the rights to use, copy, modify, merge, publish,
  11. // distribute, sublicense, and/or sell copies of the Software, and to
  12. // permit persons to whom the Software is furnished to do so, subject to
  13. // the following conditions:
  14. //
  15. // The above copyright notice and this permission notice shall be
  16. // included in all copies or substantial portions of the Software.
  17. //
  18. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  22. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  23. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. //
  26. using System;
  27. using System.Collections;
  28. using System.Collections.Generic;
  29. using System.Collections.ObjectModel;
  30. using System.ComponentModel;
  31. using System.Configuration;
  32. using System.Reflection;
  33. using System.ServiceModel;
  34. using System.ServiceModel.Channels;
  35. using System.ServiceModel.Description;
  36. using System.ServiceModel.Diagnostics;
  37. using System.ServiceModel.Dispatcher;
  38. using System.ServiceModel.MsmqIntegration;
  39. using System.ServiceModel.PeerResolvers;
  40. using System.ServiceModel.Security;
  41. using System.ServiceModel.Web;
  42. using System.Runtime.Serialization;
  43. using System.Text;
  44. using System.Xml;
  45. namespace System.ServiceModel.Configuration
  46. {
  47. public class WebHttpEndpointElement : StandardEndpointElement
  48. {
  49. static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection ();
  50. static ConfigurationProperty content_type_mapper, cross_domain_script_access_enabled, host_name_comparison_mode, max_buffer_pool_size, max_buffer_size, max_received_message_size, reader_quotas, security, transfer_mode, write_encoding, automatic_format_selection_enabled, default_outgoing_response_format, fault_exception_enabled, help_enabled;
  51. static WebHttpEndpointElement ()
  52. {
  53. content_type_mapper = new ConfigurationProperty ("contentTypeMapper", typeof (string), "", null, null, ConfigurationPropertyOptions.None);
  54. cross_domain_script_access_enabled = new ConfigurationProperty ("crossDomainScriptAccessEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  55. host_name_comparison_mode = new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), HostNameComparisonMode.StrongWildcard, null, null, ConfigurationPropertyOptions.None);
  56. max_buffer_pool_size = new ConfigurationProperty ("maxBufferPoolSize", typeof (long), 0x80000L, null, null, ConfigurationPropertyOptions.None);
  57. max_buffer_size = new ConfigurationProperty ("maxBufferSize", typeof (int), 0x10000, null, null, ConfigurationPropertyOptions.None);
  58. max_received_message_size = new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), 0x10000L, null, null, ConfigurationPropertyOptions.None);
  59. reader_quotas = new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotas), null, null, null, ConfigurationPropertyOptions.None);
  60. security = new ConfigurationProperty ("security", typeof (WebHttpSecurity), null, null, null, ConfigurationPropertyOptions.None);
  61. transfer_mode = new ConfigurationProperty ("transferMode", typeof (TransferMode), TransferMode.Buffered, null, null, ConfigurationPropertyOptions.None);
  62. write_encoding = new ConfigurationProperty ("writeEncoding", typeof (Encoding), "utf-8", new EncodingConverter (), null, ConfigurationPropertyOptions.None);
  63. automatic_format_selection_enabled = new ConfigurationProperty ("automaticFormatSelectionEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  64. default_outgoing_response_format = new ConfigurationProperty ("defaultOutgoingResponseFormat", typeof (WebMessageFormat), WebMessageFormat.Xml, null, null, ConfigurationPropertyOptions.None);
  65. fault_exception_enabled = new ConfigurationProperty ("faultExceptionEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  66. help_enabled = new ConfigurationProperty ("helpEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
  67. foreach (var item in new ConfigurationProperty [] {content_type_mapper, cross_domain_script_access_enabled, host_name_comparison_mode, max_buffer_pool_size, max_buffer_size, max_received_message_size, reader_quotas, security, transfer_mode, write_encoding, automatic_format_selection_enabled, default_outgoing_response_format, fault_exception_enabled, help_enabled})
  68. properties.Add (item);
  69. }
  70. protected internal override Type EndpointType {
  71. get { return typeof (WebHttpEndpoint); }
  72. }
  73. protected override ConfigurationPropertyCollection Properties {
  74. get { return properties; }
  75. }
  76. [ConfigurationProperty ("contentTypeMapper", DefaultValue = "")]
  77. [StringValidator (MinLength = 0)]
  78. public string ContentTypeMapper {
  79. get { return (string) this ["contentTypeMapper"]; }
  80. set { this ["contentTypeMapper"] = value; }
  81. }
  82. [ConfigurationProperty ("crossDomainScriptAccessEnabled", DefaultValue = false)]
  83. public bool CrossDomainScriptAccessEnabled {
  84. get { return (bool) this ["crossDomainScriptAccessEnabled"]; }
  85. set { this ["crossDomainScriptAccessEnabled"] = value; }
  86. }
  87. [ConfigurationProperty ("hostNameComparisonMode", DefaultValue = HostNameComparisonMode.StrongWildcard)]
  88. public HostNameComparisonMode HostNameComparisonMode {
  89. get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
  90. set { this ["hostNameComparisonMode"] = value; }
  91. }
  92. [LongValidator (MinValue = 0, MaxValue = long.MaxValue, ExcludeRange = false)]
  93. [ConfigurationProperty ("maxBufferPoolSize", DefaultValue = 0x80000,
  94. Options = ConfigurationPropertyOptions.None)]
  95. public long MaxBufferPoolSize {
  96. get { return (long) this ["maxBufferPoolSize"]; }
  97. set { this ["maxBufferPoolSize"] = value; }
  98. }
  99. [IntegerValidator ( MinValue = 1,
  100. MaxValue = int.MaxValue,
  101. ExcludeRange = false)]
  102. [ConfigurationProperty ("maxBufferSize", DefaultValue = 0x10000,
  103. Options = ConfigurationPropertyOptions.None)]
  104. public int MaxBufferSize {
  105. get { return (int) this ["maxBufferSize"]; }
  106. set { this ["maxBufferSize"] = value; }
  107. }
  108. [LongValidator ( MinValue = 1, MaxValue = long.MaxValue, ExcludeRange = false)]
  109. [ConfigurationProperty ("maxReceivedMessageSize", DefaultValue = 0x10000,
  110. Options = ConfigurationPropertyOptions.None)]
  111. public long MaxReceivedMessageSize {
  112. get { return (long) this ["maxReceivedMessageSize"]; }
  113. set { this ["maxReceivedMessageSize"] = value; }
  114. }
  115. [ConfigurationProperty ("readerQuotas")]
  116. public XmlDictionaryReaderQuotasElement ReaderQuotas {
  117. get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
  118. }
  119. [ConfigurationProperty ("security")]
  120. public WebHttpSecurityElement Security {
  121. get { return (WebHttpSecurityElement) this ["security"]; }
  122. }
  123. [ConfigurationProperty ("transferMode", DefaultValue = TransferMode.Buffered)]
  124. public TransferMode TransferMode {
  125. get { return (TransferMode) this ["transferMode"]; }
  126. set { this ["transferMode"] = value; }
  127. }
  128. [TypeConverter (typeof (EncodingConverter))]
  129. [ConfigurationProperty ("writeEncoding", DefaultValue = "utf-8")]
  130. public Encoding WriteEncoding {
  131. get { return (Encoding) this ["writeEncoding"]; }
  132. set { this ["writeEncoding"] = value; }
  133. }
  134. [ConfigurationProperty ("automaticFormatSelectionEnabled", DefaultValue = false)]
  135. public bool AutomaticFormatSelectionEnabled {
  136. get { return (bool) this ["automaticFormatSelectionEnabled"]; }
  137. set { this ["automaticFormatSelectionEnabled"] = value; }
  138. }
  139. [ConfigurationProperty ("defaultOutgoingResponseFormat", DefaultValue = WebMessageFormat.Xml)]
  140. public WebMessageFormat DefaultOutgoingResponseFormat {
  141. get { return (WebMessageFormat) this ["defaultOutgoingResponseFormat"]; }
  142. set { this ["defaultOutgoingResponseFormat"] = value; }
  143. }
  144. [ConfigurationProperty ("faultExceptionEnabled", DefaultValue = false)]
  145. public bool FaultExceptionEnabled {
  146. get { return (bool) this ["faultExceptionEnabled"]; }
  147. set { this ["faultExceptionEnabled"] = value; }
  148. }
  149. [ConfigurationProperty ("helpEnabled", DefaultValue = false)]
  150. public bool HelpEnabled {
  151. get { return (bool) this ["helpEnabled"]; }
  152. set { this ["helpEnabled"] = value; }
  153. }
  154. protected internal override ServiceEndpoint CreateServiceEndpoint (ContractDescription contractDescription)
  155. {
  156. throw new NotImplementedException ();
  157. }
  158. protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
  159. {
  160. throw new NotImplementedException ();
  161. }
  162. protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
  163. {
  164. throw new NotImplementedException ();
  165. }
  166. protected override void OnInitializeAndValidate (ChannelEndpointElement channelEndpointElement)
  167. {
  168. throw new NotImplementedException ();
  169. }
  170. protected override void OnInitializeAndValidate (ServiceEndpointElement serviceEndpointElement)
  171. {
  172. throw new NotImplementedException ();
  173. }
  174. }
  175. }